]> granicus.if.org Git - imagemagick/commitdiff
Fixed memory leak.
authorDirk Lemstra <dirk@git.imagemagick.org>
Thu, 18 Jan 2018 20:29:22 +0000 (21:29 +0100)
committerDirk Lemstra <dirk@git.imagemagick.org>
Thu, 18 Jan 2018 20:29:22 +0000 (21:29 +0100)
Credit to OSS-Fuzz

coders/miff.c
coders/mpc.c

index ea499ee0ef1716ac2215e22cc0075080bbfc1ff2..dfbc2f591601f3067d52f4016bf487c874a241ff 100644 (file)
@@ -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,
index 421bf545a81109a8e2977491c9c2e0e58fbba0a0..72f725acb6cec8888a32f71f66c1d8a6a7679462 100644 (file)
@@ -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,