mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-27 09:44: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;
|
Imaging im;
|
||||||
|
|
||||||
im = (Imaging) calloc(1, size);
|
|
||||||
if (!im)
|
|
||||||
return (Imaging) ImagingError_MemoryError();
|
|
||||||
|
|
||||||
/* linesize overflow check, roughly the current largest space req'd */
|
/* linesize overflow check, roughly the current largest space req'd */
|
||||||
if (xsize > (INT_MAX / 4) - 1) {
|
if (xsize > (INT_MAX / 4) - 1) {
|
||||||
return (Imaging) ImagingError_MemoryError();
|
return (Imaging) ImagingError_MemoryError();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
im = (Imaging) calloc(1, size);
|
||||||
|
if (!im) {
|
||||||
|
return (Imaging) ImagingError_MemoryError();
|
||||||
|
}
|
||||||
|
|
||||||
/* Setup image descriptor */
|
/* Setup image descriptor */
|
||||||
im->xsize = xsize;
|
im->xsize = xsize;
|
||||||
im->ysize = ysize;
|
im->ysize = ysize;
|
||||||
|
@ -228,8 +229,7 @@ Imaging
|
||||||
ImagingNewPrologue(const char *mode, int xsize, int ysize)
|
ImagingNewPrologue(const char *mode, int xsize, int ysize)
|
||||||
{
|
{
|
||||||
return ImagingNewPrologueSubtype(
|
return ImagingNewPrologueSubtype(
|
||||||
mode, xsize, ysize, sizeof(struct ImagingMemoryInstance)
|
mode, xsize, ysize, sizeof(struct ImagingMemoryInstance));
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Imaging
|
Imaging
|
||||||
|
@ -371,7 +371,6 @@ ImagingNewBlock(const char *mode, int xsize, int ysize)
|
||||||
}
|
}
|
||||||
|
|
||||||
im->destroy = ImagingDestroyBlock;
|
im->destroy = ImagingDestroyBlock;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ImagingNewEpilogue(im);
|
return ImagingNewEpilogue(im);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user