Bug in PIL's quantize()

Germán M. Bravo <[email protected]> Wed, 20 Jun 2012 17:55:38 -0500
Newsgroups gmane.comp.python.image
Message-ID <CA+98ED=j2AeCNsbYZ3k87hOi+6vymbWgFBevMv4X+741_2fs5g@mail.gmail.com>
I found a nasty bug in PIL's quantize(), in Quant.c,
map_image_pixels_from_median_box(), the `int pixelVal;` definition
must be `unsigned long pixelVal;` instead... This was making PIL crash
under certain circumstances in my system (64 bit Mac OS X Lion 10.7.4
using llvm-gcc4.2).

Patch follows:

-------- CUT HERE --------
--- libImaging/Quant.c.orig	2012-06-20 17:53:49.000000000 -0500
+++ libImaging/Quant.c	2012-06-20 17:53:51.000000000 -0500
@@ -914,7 +914,7 @@
    unsigned long bestdist,bestmatch,dist;
    unsigned long initialdist;
    HashTable h2;
-   int pixelVal;
+   unsigned long pixelVal;

    h2=hashtable_new(unshifted_pixel_hash,unshifted_pixel_cmp);
    for (i=0;i<nPixels;i++) {
-------- CUT HERE --------
_______________________________________________
Image-SIG maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/image-sig