mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-26 17:24:31 +03:00
check args before allocate memory
This commit is contained in:
parent
430c53707f
commit
152104bba3
|
@ -50,15 +50,16 @@ ImagingNewPrologueSubtype(const char *mode, int xsize, int ysize, int size)
|
|||
{
|
||||
Imaging im;
|
||||
|
||||
im = (Imaging) calloc(1, size);
|
||||
if (!im)
|
||||
return (Imaging) ImagingError_MemoryError();
|
||||
|
||||
/* linesize overflow check, roughly the current largest space req'd */
|
||||
if (xsize > (INT_MAX / 4) - 1) {
|
||||
return (Imaging) ImagingError_MemoryError();
|
||||
}
|
||||
|
||||
im = (Imaging) calloc(1, size);
|
||||
if (!im) {
|
||||
return (Imaging) ImagingError_MemoryError();
|
||||
}
|
||||
|
||||
/* Setup image descriptor */
|
||||
im->xsize = xsize;
|
||||
im->ysize = ysize;
|
||||
|
@ -228,8 +229,7 @@ Imaging
|
|||
ImagingNewPrologue(const char *mode, int xsize, int ysize)
|
||||
{
|
||||
return ImagingNewPrologueSubtype(
|
||||
mode, xsize, ysize, sizeof(struct ImagingMemoryInstance)
|
||||
);
|
||||
mode, xsize, ysize, sizeof(struct ImagingMemoryInstance));
|
||||
}
|
||||
|
||||
Imaging
|
||||
|
@ -371,7 +371,6 @@ ImagingNewBlock(const char *mode, int xsize, int ysize)
|
|||
}
|
||||
|
||||
im->destroy = ImagingDestroyBlock;
|
||||
|
||||
}
|
||||
|
||||
return ImagingNewEpilogue(im);
|
||||
|
|
Loading…
Reference in New Issue
Block a user