diff --git a/ext/gd/libgd/gd_gif_in.c b/ext/gd/libgd/gd_gif_in.c index 6fb79fd00b6b..0204c4158db4 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 000000000000..b3aa80d843a9 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 000000000000..c962c0e9b20f --- /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)