From 3ffcd9770cef435e10b0a5890d36501d1153e729 Mon Sep 17 00:00:00 2001 From: Lukasz Kozuchowski Date: Sun, 29 Jan 2017 07:20:44 +0100 Subject: [PATCH 1/2] BUG fix: '' in image mode no longer causes a crash --- libImaging/Storage.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libImaging/Storage.c b/libImaging/Storage.c index 27661bfdb..fb27572d3 100644 --- a/libImaging/Storage.c +++ b/libImaging/Storage.c @@ -398,6 +398,9 @@ ImagingNew(const char* mode, int xsize, int ysize) int bytes; Imaging im; + if (strcmp(mode, "") == 0) + return (Imaging) ImagingError_ValueError("empty mode"); + if (strlen(mode) == 1) { if (mode[0] == 'F' || mode[0] == 'I') bytes = 4; From 3e317f3ca0aab1688f813a771885ce1f4fdb047a Mon Sep 17 00:00:00 2001 From: Lukasz Kozuchowski Date: Sun, 29 Jan 2017 07:50:28 +0100 Subject: [PATCH 2/2] Empty image mode test --- Tests/test_image.py | 1 + 1 file changed, 1 insertion(+) diff --git a/Tests/test_image.py b/Tests/test_image.py index c79930e76..bb2110632 100644 --- a/Tests/test_image.py +++ b/Tests/test_image.py @@ -29,6 +29,7 @@ class TestImage(PillowTestCase): self.assertEqual(im3.getcolors(), [(10000, 0)]) self.assertRaises(ValueError, lambda: Image.new("X", (100, 100))) + self.assertRaises(ValueError, lambda: Image.new("", (100, 100))) # self.assertRaises( # MemoryError, lambda: Image.new("L", (1000000, 1000000)))