From: Pierre Joye Date: Fri, 8 Jun 2007 05:25:52 +0000 (+0000) Subject: - MFB: #41630, fix segfault when an invalid color index is present in the X-Git-Tag: BEFORE_IMPORT_OF_MYSQLND~490 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7114e613d8af0302b44d55e97b4dcabe858edc9f;p=php - MFB: #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 7076518c72..21409c5733 100644 --- a/ext/gd/libgd/gd_gif_in.c +++ b/ext/gd/libgd/gd_gif_in.c @@ -590,6 +590,10 @@ ReadImage(gdImagePtr im, gdIOCtx *fd, int len, int height, unsigned char (*cmap) /*} */ 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;