From: root <356986351@qq.com> Date: Fri, 15 Sep 2017 10:27:41 +0000 (+0000) Subject: fix memory leak X-Git-Tag: 7.0.7-3~23 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=423703c989e17ccd6bed6e9e8290515f2d617592;p=imagemagick fix memory leak fix memory leak --- diff --git a/coders/sixel.c b/coders/sixel.c index 51cc4eec7..7af17f5aa 100644 --- a/coders/sixel.c +++ b/coders/sixel.c @@ -1034,7 +1034,11 @@ static Image *ReadSIXELImage(const ImageInfo *image_info,ExceptionInfo *exceptio image->storage_class=PseudoClass; status=SetImageExtent(image,image->columns,image->rows,exception); if (status == MagickFalse) - return(DestroyImageList(image)); + { + sixel_pixels=(unsigned char *) RelinquishMagickMemory(sixel_pixels); + sixel_palette=(unsigned char *) RelinquishMagickMemory(sixel_palette); + return(DestroyImageList(image)); + } if (AcquireImageColormap(image,image->colors, exception) == MagickFalse) { diff --git a/coders/tim.c b/coders/tim.c index 7f87292c6..32af8e268 100644 --- a/coders/tim.c +++ b/coders/tim.c @@ -240,7 +240,10 @@ static Image *ReadTIMImage(const ImageInfo *image_info,ExceptionInfo *exception) ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); count=ReadBlob(image,image_size,tim_data); if (count != (ssize_t) (image_size)) - ThrowReaderException(CorruptImageError,"InsufficientImageDataInFile"); + { + tim_data=(unsigned char *) RelinquishMagickMemory(tim_data); + ThrowReaderException(CorruptImageError,"InsufficientImageDataInFile"); + } tim_pixels=tim_data; /* Initialize image structure. @@ -383,7 +386,10 @@ static Image *ReadTIMImage(const ImageInfo *image_info,ExceptionInfo *exception) break; } default: - ThrowReaderException(CorruptImageError,"ImproperImageHeader"); + { + tim_data=(unsigned char *) RelinquishMagickMemory(tim_data); + ThrowReaderException(CorruptImageError,"ImproperImageHeader"); + } } if (image->storage_class == PseudoClass) (void) SyncImage(image,exception);