int->py_ssize_t for potentially large numbers

This commit is contained in:
Eric Soroos 2013-12-13 15:16:14 -08:00
parent 631612edc6
commit 1060a59de9

View File

@ -325,15 +325,15 @@ Imaging
ImagingNewBlock(const char *mode, int xsize, int ysize) ImagingNewBlock(const char *mode, int xsize, int ysize)
{ {
Imaging im; Imaging im;
int y, i; Py_ssize_t y, i;
int bytes; Py_ssize_t bytes;
im = ImagingNewPrologue(mode, xsize, ysize); im = ImagingNewPrologue(mode, xsize, ysize);
if (!im) if (!im)
return NULL; return NULL;
/* Use a single block */ /* Use a single block */
bytes = im->ysize * im->linesize; bytes = (Py_ssize_t) im->ysize * im->linesize;
if (bytes <= 0) if (bytes <= 0)
/* some platforms return NULL for malloc(0); this fix /* some platforms return NULL for malloc(0); this fix
prevents MemoryError on zero-sized images on such prevents MemoryError on zero-sized images on such