mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-05-30 02:33:07 +03:00
overflow check for im->linesize
This commit is contained in:
parent
d48e5cd500
commit
768936fa33
|
@ -56,6 +56,11 @@ ImagingNewPrologueSubtype(const char *mode, int xsize, int ysize,
|
||||||
if (!im)
|
if (!im)
|
||||||
return (Imaging) ImagingError_MemoryError();
|
return (Imaging) ImagingError_MemoryError();
|
||||||
|
|
||||||
|
/* linesize overflow check, roughly the current largest space req'd */
|
||||||
|
if (xsize > (INT_MAX / 4) - 1) {
|
||||||
|
return (Imaging) ImagingError_MemoryError();
|
||||||
|
}
|
||||||
|
|
||||||
/* Setup image descriptor */
|
/* Setup image descriptor */
|
||||||
im->xsize = xsize;
|
im->xsize = xsize;
|
||||||
im->ysize = ysize;
|
im->ysize = ysize;
|
||||||
|
@ -306,8 +311,8 @@ ImagingNewArray(const char *mode, int xsize, int ysize)
|
||||||
|
|
||||||
/* Allocate image as an array of lines */
|
/* Allocate image as an array of lines */
|
||||||
for (y = 0; y < im->ysize; y++) {
|
for (y = 0; y < im->ysize; y++) {
|
||||||
/* malloc check UNDONE - where is linesize set? */
|
/* malloc check linesize checked in prologue */
|
||||||
p = (char *) malloc(im->linesize);
|
p = (char *) calloc(1, im->linesize);
|
||||||
if (!p) {
|
if (!p) {
|
||||||
ImagingDestroyArray(im);
|
ImagingDestroyArray(im);
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user