From: root <356986351@qq.com> Date: Fri, 15 Sep 2017 16:51:13 +0000 (+0000) Subject: fix memory leak in gif X-Git-Tag: 7.0.7-3~17 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1fdb9b3255830d53c044c6db6e061ea7bd137fa4;p=imagemagick fix memory leak in gif --- diff --git a/coders/gif.c b/coders/gif.c index 6202f5e16..d87279f5f 100644 --- a/coders/gif.c +++ b/coders/gif.c @@ -1156,6 +1156,7 @@ static Image *ReadGIFImage(const ImageInfo *image_info,ExceptionInfo *exception) if (info == (unsigned char *) NULL) { meta_image=DestroyImage(meta_image); + global_colormap=(unsigned char *) RelinquishMagickMemory(global_colormap); ThrowReaderException(ResourceLimitError, "MemoryAllocationFailed"); } @@ -1174,6 +1175,7 @@ static Image *ReadGIFImage(const ImageInfo *image_info,ExceptionInfo *exception) if (info == (unsigned char *) NULL) { meta_image=DestroyImage(meta_image); + global_colormap=(unsigned char *) RelinquishMagickMemory(global_colormap); ThrowReaderException(ResourceLimitError, "MemoryAllocationFailed"); } @@ -1183,6 +1185,7 @@ static Image *ReadGIFImage(const ImageInfo *image_info,ExceptionInfo *exception) if (profile == (StringInfo *) NULL) { meta_image=DestroyImage(meta_image); + global_colormap=(unsigned char *) RelinquishMagickMemory(global_colormap); ThrowReaderException(ResourceLimitError, "MemoryAllocationFailed"); } @@ -1355,7 +1358,11 @@ static Image *ReadGIFImage(const ImageInfo *image_info,ExceptionInfo *exception) break; status=SetImageExtent(image,image->columns,image->rows,exception); if (status == MagickFalse) - return(DestroyImageList(image)); + { + global_colormap=(unsigned char *) RelinquishMagickMemory(global_colormap); + meta_image=DestroyImage(meta_image); + return(DestroyImageList(image)); + } /* Decode image. */