Index: libgd-2.2.5/src/gd_gif_in.c =================================================================== --- libgd-2.2.5.orig/src/gd_gif_in.c 2018-01-22 15:19:35.417382486 +0100 +++ libgd-2.2.5/src/gd_gif_in.c 2018-01-22 15:21:28.683291084 +0100 @@ -335,11 +335,6 @@ terminated: return 0; } - if(!im->colorsTotal) { - gdImageDestroy(im); - return 0; - } - /* Check for open colors at the end, so * we can reduce colorsTotal and ultimately * BitsPerPixel */ @@ -351,6 +346,11 @@ terminated: } } + if(!im->colorsTotal) { + gdImageDestroy(im); + return 0; + } + return im; } @@ -447,7 +447,7 @@ static int GetCode_(gdIOCtx *fd, CODE_STATIC_DATA *scd, int code_size, int flag, int *ZeroDataBlockP) { int i, j, ret; - unsigned char count; + int count; if(flag) { scd->curbit = 0;