From: Pierre Joye Date: Wed, 4 Apr 2007 11:42:54 +0000 (+0000) Subject: - MFH: X-Git-Tag: RELEASE_1_1_0~64 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=19ac790b358baf592a7f4584e869566b2cad2b34;p=php - MFH: - do not try to use the global color map when none was found (Nuno, Pierre) - free im on error --- diff --git a/ext/gd/libgd/gd_gif_in.c b/ext/gd/libgd/gd_gif_in.c index 32c31b56f8..7076518c72 100644 --- a/ext/gd/libgd/gd_gif_in.c +++ b/ext/gd/libgd/gd_gif_in.c @@ -143,7 +143,7 @@ gdImagePtr gdImageCreateFromGifCtx(gdIOCtxPtr fd) /* {{{ */ /*1.4//int imageCount = 0; */ int ZeroDataBlock = FALSE; - + int haveGlobalColormap; gdImagePtr im = 0; /*1.4//imageNumber = 1; */ @@ -175,11 +175,13 @@ gdImagePtr gdImageCreateFromGifCtx(gdIOCtxPtr fd) /* {{{ */ screen_width = imw = LM_to_uint(buf[0],buf[1]); screen_height = imh = LM_to_uint(buf[2],buf[3]); - if (BitSet(buf[4], LOCALCOLORMAP)) { /* Global Colormap */ + haveGlobalColormap = BitSet(buf[4], LOCALCOLORMAP); /* Global Colormap */ + if (haveGlobalColormap) { if (ReadColorMap(fd, BitPixel, ColorMap)) { return 0; } } + for (;;) { int top, left; int width, height; @@ -230,11 +232,16 @@ gdImagePtr gdImageCreateFromGifCtx(gdIOCtxPtr fd) /* {{{ */ im->interlace = BitSet(buf[8], INTERLACE); if (!useGlobalColormap) { if (ReadColorMap(fd, bitPixel, localColorMap)) { + gdImageDestroy(im); return 0; } ReadImage(im, fd, width, height, localColorMap, BitSet(buf[8], INTERLACE), &ZeroDataBlock); } else { + if (!haveGlobalColormap) { + gdImageDestroy(im); + return 0; + } ReadImage(im, fd, width, height, ColorMap, BitSet(buf[8], INTERLACE), &ZeroDataBlock);