diff -rupN giflib-5.2.1/gif2rgb.c giflib-5.2.1-new/gif2rgb.c --- giflib-5.2.1/gif2rgb.c 2019-06-24 09:24:27.000000000 +0200 +++ giflib-5.2.1-new/gif2rgb.c 2022-07-21 09:58:28.256036156 +0200 @@ -294,6 +294,11 @@ static void DumpScreen2RGB(char *FileNam GifRow = ScreenBuffer[i]; GifQprintf("\b\b\b\b%-4d", ScreenHeight - i); for (j = 0, BufferP = Buffer; j < ScreenWidth; j++) { + /* Check if color is within color palete */ + if (GifRow[j] >= ColorMap->ColorCount) + { + GIF_EXIT(GifErrorString(D_GIF_ERR_IMAGE_DEFECT)); + } ColorMapEntry = &ColorMap->Colors[GifRow[j]]; *BufferP++ = ColorMapEntry->Red; *BufferP++ = ColorMapEntry->Green;