Merge pull request #2380 from evalapply/master

BUG fix: '' in image mode no longer causes a crash
This commit is contained in:
wiredfool 2017-01-31 19:03:29 +00:00 committed by GitHub
commit b93025fa5b
2 changed files with 4 additions and 0 deletions

View File

@ -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)))

View File

@ -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;