]> granicus.if.org Git - php/commitdiff
- #41630, fix segfault when an invalid color index is present in the image
authorPierre Joye <pajoye@php.net>
Thu, 7 Jun 2007 21:07:33 +0000 (21:07 +0000)
committerPierre Joye <pajoye@php.net>
Thu, 7 Jun 2007 21:07:33 +0000 (21:07 +0000)
  data

ext/gd/libgd/gd_gif_in.c

index 8ee77b02e88847e86323c53529f64762fc23a8e5..ee88a2fc8e102720526f9b37ec17c46f4a383484 100644 (file)
@@ -586,7 +586,10 @@ ReadImage(gdImagePtr im, gdIOCtx *fd, int len, int height, unsigned char (*cmap)
        /*        return; */
        /*} */
 
-       while ((v = LWZReadByte(fd, &sd, FALSE, c, ZeroDataBlockP)) >= 0 ) {
+       while ((v = LWZReadByte(fd, &sd, FALSE, c, ZeroDataBlockP)) >= 0) {
+               if (v >= gdMaxColors) {
+                       v = 0;
+               }
                /* This how we recognize which colors are actually used. */
                if (im->open[v]) {
                        im->open[v] = 0;