mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-10 19:56:47 +03:00
Avoid division by zero
This commit is contained in:
parent
0764b2b5e9
commit
a662443b7f
4
map.c
4
map.c
|
@ -342,7 +342,7 @@ PyImaging_MapBuffer(PyObject* self, PyObject* args)
|
|||
stride = xsize * 4;
|
||||
}
|
||||
|
||||
if (ysize > INT_MAX / stride) {
|
||||
if (stride > 0 && ysize > INT_MAX / stride) {
|
||||
PyErr_SetString(PyExc_MemoryError, "Integer overflow in ysize");
|
||||
return NULL;
|
||||
}
|
||||
|
@ -352,7 +352,7 @@ PyImaging_MapBuffer(PyObject* self, PyObject* args)
|
|||
if (offset > PY_SSIZE_T_MAX - size) {
|
||||
PyErr_SetString(PyExc_MemoryError, "Integer overflow in offset");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* check buffer size */
|
||||
if (PyImaging_GetBuffer(target, &view) < 0)
|
||||
|
|
Loading…
Reference in New Issue
Block a user