diff --git a/Tests/32bit_segfault_test.py b/Tests/32bit_segfault_test.py new file mode 100644 index 000000000..958bc6b3c --- /dev/null +++ b/Tests/32bit_segfault_test.py @@ -0,0 +1,7 @@ +#!/usr/bin/env python + +from PIL import Image + +im = Image.new('L', (999999, 999999), 0) + + diff --git a/libImaging/ImPlatform.h b/libImaging/ImPlatform.h index be1f20f3f..70ee63119 100644 --- a/libImaging/ImPlatform.h +++ b/libImaging/ImPlatform.h @@ -69,4 +69,6 @@ #define FLOAT32 float #define FLOAT64 double - +#ifdef _MSC_VER +typedef signed __int64 int64_t; +#endif diff --git a/libImaging/Storage.c b/libImaging/Storage.c index d31db5cb2..c6d2e5c5e 100644 --- a/libImaging/Storage.c +++ b/libImaging/Storage.c @@ -379,7 +379,7 @@ ImagingNew(const char* mode, int xsize, int ysize) } else bytes = strlen(mode); /* close enough */ - if ((Py_ssize_t) xsize * ysize * bytes <= THRESHOLD) { + if ((int64_t) xsize * (int64_t) ysize * bytes <= THRESHOLD) { im = ImagingNewBlock(mode, xsize, ysize); if (im) return im;