(pbm_load): Check image size for monochrome pbm.
authorChong Yidong <cyd@stupidchicken.com>
Mon, 14 May 2007 14:53:15 +0000 (14:53 +0000)
committerChong Yidong <cyd@stupidchicken.com>
Mon, 14 May 2007 14:53:15 +0000 (14:53 +0000)
src/image.c

index eacea4a..12b27fe 100644 (file)
@@ -5730,7 +5730,17 @@ pbm_load (f, img)
            if (raw_p)
              {
                if ((x & 7) == 0)
-                 c = *p++;
+                 {
+                   if (p >= end)
+                     {
+                       x_destroy_x_image (ximg);
+                       x_clear_image (f, img);
+                       image_error ("Invalid image size in image `%s'",
+                                    img->spec, Qnil);
+                       goto error;
+                     }
+                   c = *p++;
+                 }
                g = c & 0x80;
                c <<= 1;
              }