diff --git a/examples/gifdec.c b/examples/gifdec.c index f921c0a4..feb84e6e 100644 --- a/examples/gifdec.c +++ b/examples/gifdec.c @@ -87,7 +87,8 @@ static void Remap(const GifFileType* const gif, const uint8_t* const src, const GifColorType* colors; const ColorMapObject* const cmap = gif->Image.ColorMap ? gif->Image.ColorMap : gif->SColorMap; - if (cmap == NULL) return; + if (cmap == NULL || cmap->Colors == NULL) return; + if (len > cmap->ColorCount) len = cmap->ColorCount; colors = cmap->Colors; for (i = 0; i < len; ++i) {