From: Dirk Lemstra Date: Thu, 18 Jan 2018 20:29:22 +0000 (+0100) Subject: Fixed memory leak. X-Git-Tag: 7.0.7-22~37 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=24372750c186639d6ebb95fa5f2736d53154c024;p=imagemagick Fixed memory leak. Credit to OSS-Fuzz --- diff --git a/coders/miff.c b/coders/miff.c index ea499ee0e..dfbc2f591 100644 --- a/coders/miff.c +++ b/coders/miff.c @@ -549,7 +549,11 @@ static Image *ReadMIFFImage(const ImageInfo *image_info, *p=(char) c; } if (comment == (char *) NULL) - ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); + { + options=DestroyString(options); + ThrowReaderException(ResourceLimitError, + "MemoryAllocationFailed"); + } *p='\0'; (void) SetImageProperty(image,"comment",comment,exception); comment=DestroyString(comment); @@ -900,6 +904,7 @@ static Image *ReadMIFFImage(const ImageInfo *image_info, StringToLong(options)); if (profile == (StringInfo *) NULL) { + options=DestroyString(options); profiles=DestroyLinkedList(profiles, RelinquishMagickMemory); ThrowReaderException(ResourceLimitError, diff --git a/coders/mpc.c b/coders/mpc.c index 421bf545a..72f725acb 100644 --- a/coders/mpc.c +++ b/coders/mpc.c @@ -265,7 +265,11 @@ static Image *ReadMPCImage(const ImageInfo *image_info,ExceptionInfo *exception) *p=(char) c; } if (comment == (char *) NULL) - ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); + { + options=DestroyString(options); + ThrowReaderException(ResourceLimitError, + "MemoryAllocationFailed"); + } *p='\0'; (void) SetImageProperty(image,"comment",comment,exception); comment=DestroyString(comment); @@ -632,6 +636,7 @@ static Image *ReadMPCImage(const ImageInfo *image_info,ExceptionInfo *exception) StringToLong(options)); if (profile == (StringInfo *) NULL) { + options=DestroyString(options); profiles=DestroyLinkedList(profiles, RelinquishMagickMemory); ThrowReaderException(ResourceLimitError,