From 1fdb9b3255830d53c044c6db6e061ea7bd137fa4 Mon Sep 17 00:00:00 2001 From: root <356986351@qq.com> Date: Fri, 15 Sep 2017 16:51:13 +0000 Subject: [PATCH] fix memory leak in gif --- coders/gif.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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. */ -- 2.40.0