mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-07-04 11:53:32 +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;
|
stride = xsize * 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ysize > INT_MAX / stride) {
|
if (stride > 0 && ysize > INT_MAX / stride) {
|
||||||
PyErr_SetString(PyExc_MemoryError, "Integer overflow in ysize");
|
PyErr_SetString(PyExc_MemoryError, "Integer overflow in ysize");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -352,7 +352,7 @@ PyImaging_MapBuffer(PyObject* self, PyObject* args)
|
||||||
if (offset > PY_SSIZE_T_MAX - size) {
|
if (offset > PY_SSIZE_T_MAX - size) {
|
||||||
PyErr_SetString(PyExc_MemoryError, "Integer overflow in offset");
|
PyErr_SetString(PyExc_MemoryError, "Integer overflow in offset");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* check buffer size */
|
/* check buffer size */
|
||||||
if (PyImaging_GetBuffer(target, &view) < 0)
|
if (PyImaging_GetBuffer(target, &view) < 0)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user