From 86fa069bec23f72077dbcb9f74bc344a5e53b504 Mon Sep 17 00:00:00 2001 From: Christian Schneider Date: Wed, 7 Jun 2017 07:01:58 +0200 Subject: [PATCH] Fx issue #59 - Unhandled GIF_ERROR led to accessing uninitialized memory --- precomp.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/precomp.cpp b/precomp.cpp index 633335f..5fcc686 100644 --- a/precomp.cpp +++ b/precomp.cpp @@ -6972,7 +6972,15 @@ bool recompress_gif(FILE* srcfile, FILE* dstfile, unsigned char block_size, GifC } // this does send a clear code, so we pass g and gd - EGifPutImageDesc(newGifFile, g, gd, Row, Col, Width, Height, myGifFile->Image.Interlace, myGifFile->Image.ColorMap); + if (EGifPutImageDesc(newGifFile, g, gd, Row, Col, Width, Height, myGifFile->Image.Interlace, myGifFile->Image.ColorMap) == GIF_ERROR) { + for (i = 0; i < myGifFile->SHeight; i++) { + delete[] ScreenBuff[i]; + } + delete[] ScreenBuff; + DGifCloseFile(myGifFile); + EGifCloseFile(newGifFile); + return false; + } newgif_may_write = true;