From: Pierre Joye Date: Thu, 7 Jun 2007 21:07:33 +0000 (+0000) Subject: - #41630, fix segfault when an invalid color index is present in the image X-Git-Tag: php-5.2.4RC1~385 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c4b5196d0b006ee695d4a66b13071aab26ff943b;p=php - #41630, fix segfault when an invalid color index is present in the image data --- diff --git a/ext/gd/libgd/gd_gif_in.c b/ext/gd/libgd/gd_gif_in.c index 8ee77b02e8..ee88a2fc8e 100644 --- a/ext/gd/libgd/gd_gif_in.c +++ b/ext/gd/libgd/gd_gif_in.c @@ -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;