Comment 1 for bug 346474

Revision history for this message
pipe (pipatron) wrote :

A patch that solves this issue:

pipe@vitamin:~/src/imagemagick-6.3.7.9.dfsg1$ diff -u coders/orig/pnm.c coders/pnm.c
--- coders/orig/pnm.c 2007-12-08 01:13:40.000000000 +0100
+++ coders/pnm.c 2009-03-24 21:54:47.000000000 +0100
@@ -417,7 +417,7 @@
       ThrowReaderException(CorruptImageError,"NegativeOrZeroImageSize");
     if (max_value >= 65536)
       ThrowReaderException(CorruptImageError,"ImproperImageHeader");
- for (image->depth=1; (1UL << image->depth) < max_value; image->depth++);
+ for (image->depth=1; (1UL << image->depth) <= max_value; image->depth++);
     scale=(Quantum *) NULL;
     if (image->storage_class == PseudoClass)
       if (AllocateImageColormap(image,image->colors) == MagickFalse)