Avoid division by zero

This commit is contained in:
hugovk 2017-02-22 08:28:20 +02:00
parent 0764b2b5e9
commit a662443b7f

4
map.c
View File

@ -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)