From 2750d7bac34a2c96d41aca3f81179928d10a4885 Mon Sep 17 00:00:00 2001 From: Alexander Date: Sun, 6 Aug 2017 00:50:56 +0300 Subject: [PATCH] destroy image and set MemoryError on overflow check failure --- libImaging/Storage.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libImaging/Storage.c b/libImaging/Storage.c index 6acda2af0..7ab5ae1f5 100644 --- a/libImaging/Storage.c +++ b/libImaging/Storage.c @@ -344,7 +344,8 @@ ImagingNewBlock(const char *mode, int xsize, int ysize) if (im->linesize && im->ysize > INT_MAX / im->linesize) { /* punt if we're going to overflow */ - return NULL; + ImagingDelete(im); + return (Imaging) ImagingError_MemoryError(); } if (im->ysize * im->linesize <= 0) {