From 0990dadd6d452a3c4d19af5f82c3d1999b46b09d Mon Sep 17 00:00:00 2001 From: Alexander Date: Sun, 6 Aug 2017 01:31:31 +0300 Subject: [PATCH] use accurate im->linesize instead of strlen(mode) approximation --- libImaging/Storage.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/libImaging/Storage.c b/libImaging/Storage.c index 155bac883..3c365207d 100644 --- a/libImaging/Storage.c +++ b/libImaging/Storage.c @@ -371,26 +371,17 @@ ImagingAllocateBlock(Imaging im) Imaging ImagingNew(const char* mode, int xsize, int ysize) { - int bytes; Imaging im; - if (strlen(mode) == 1) { - if (mode[0] == 'F' || mode[0] == 'I') - bytes = 4; - else - bytes = 1; - } else - bytes = strlen(mode) || 1; /* close enough */ - if (xsize < 0 || ysize < 0) { return (Imaging) ImagingError_ValueError("bad image size"); } im = ImagingNewPrologue(mode, xsize, ysize); - if (!im) + if ( ! im) return NULL; - if ((int64_t) xsize * (int64_t) ysize <= THRESHOLD / bytes) { + if (im->ysize && im->linesize <= THRESHOLD / im->ysize) { if (ImagingAllocateBlock(im)) { return im; }