Skip to content

Commit

Permalink
Avoid division by zero
Browse files Browse the repository at this point in the history
  • Loading branch information
hugovk committed Feb 22, 2017
1 parent 0764b2b commit a662443
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions map.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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)
Expand Down

0 comments on commit a662443

Please sign in to comment.