From d6bf4c260b325aa1e99786db26b4a4236a7cf711 Mon Sep 17 00:00:00 2001 From: Dirk Lemstra Date: Thu, 18 Jan 2018 21:17:02 +0100 Subject: [PATCH] Fixed memory leak. Credit to OSS-Fuzz --- coders/miff.c | 8 ++++++-- coders/mpc.c | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/coders/miff.c b/coders/miff.c index 4d80075c2..ea499ee0e 100644 --- a/coders/miff.c +++ b/coders/miff.c @@ -899,8 +899,12 @@ static Image *ReadMIFFImage(const ImageInfo *image_info, profile=BlobToStringInfo((const void *) NULL,(size_t) StringToLong(options)); if (profile == (StringInfo *) NULL) - ThrowReaderException(ResourceLimitError, - "MemoryAllocationFailed"); + { + profiles=DestroyLinkedList(profiles, + RelinquishMagickMemory); + ThrowReaderException(ResourceLimitError, + "MemoryAllocationFailed"); + } (void) SetImageProfile(image,keyword+8,profile,exception); profile=DestroyStringInfo(profile); break; diff --git a/coders/mpc.c b/coders/mpc.c index 67695ecc6..421bf545a 100644 --- a/coders/mpc.c +++ b/coders/mpc.c @@ -631,8 +631,12 @@ static Image *ReadMPCImage(const ImageInfo *image_info,ExceptionInfo *exception) profile=BlobToStringInfo((const void *) NULL,(size_t) StringToLong(options)); if (profile == (StringInfo *) NULL) - ThrowReaderException(ResourceLimitError, - "MemoryAllocationFailed"); + { + profiles=DestroyLinkedList(profiles, + RelinquishMagickMemory); + ThrowReaderException(ResourceLimitError, + "MemoryAllocationFailed"); + } (void) SetImageProfile(image,keyword+8,profile,exception); profile=DestroyStringInfo(profile); break; -- 2.40.0