diff --git a/NEWS b/NEWS index 1664d0a8d81..816055b9818 100644 --- a/NEWS +++ b/NEWS @@ -22,6 +22,8 @@ PHP NEWS images). (cmb) . Ported fix for libgd 223 (gdImageRotateGeneric() does not properly interpolate). (cmb) + . Added support for reading GIFs without colormap to bundled libgd. (Andrew + Burley, cmb) - Intl: . Fixed bug GH-11874 (intl causing segfault in docker images). (nielsdos) diff --git a/ext/gd/libgd/gd_gif_in.c b/ext/gd/libgd/gd_gif_in.c index 6fb79fd00b6..0204c4158db 100644 --- a/ext/gd/libgd/gd_gif_in.c +++ b/ext/gd/libgd/gd_gif_in.c @@ -244,8 +244,10 @@ gdImagePtr gdImageCreateFromGifCtx(gdIOCtxPtr fd) /* {{{ */ BitSet(buf[8], INTERLACE), &ZeroDataBlock); } else { if (!haveGlobalColormap) { - gdImageDestroy(im); - return 0; + // Still a valid gif, apply simple default palette as per spec + ColorMap[CM_RED][1] = 0xff; + ColorMap[CM_GREEN][1] = 0xff; + ColorMap[CM_BLUE][1] = 0xff; } ReadImage(im, fd, width, height, ColorMap, diff --git a/ext/gd/tests/gif_nocolormaps.gif b/ext/gd/tests/gif_nocolormaps.gif new file mode 100644 index 00000000000..b3aa80d843a Binary files /dev/null and b/ext/gd/tests/gif_nocolormaps.gif differ diff --git a/ext/gd/tests/gif_nocolormaps.phpt b/ext/gd/tests/gif_nocolormaps.phpt new file mode 100644 index 00000000000..c962c0e9b20 --- /dev/null +++ b/ext/gd/tests/gif_nocolormaps.phpt @@ -0,0 +1,11 @@ +--TEST-- +A GIF without any Global or Local color tables is still decoded +--EXTENSIONS-- +gd +--FILE-- + +--EXPECT-- +bool(true)