File ImageMagick-CVE-2017-9262.patch of Package ImageMagick.8768

From 4649578df8dcbfb2b08d8623d52486dc124da3a8 Mon Sep 17 00:00:00 2001
From: Dirk Lemstra <dirk@git.imagemagick.org>
Date: Sun, 7 May 2017 12:11:52 +0200
Subject: [PATCH] Fixed various memory leaks reported in #475.

---
 coders/png.c | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)

diff --git a/coders/png.c b/coders/png.c
index b3ad8360bd..a35cbf6437 100644
--- a/coders/png.c
+++ b/coders/png.c
@@ -4395,7 +4395,10 @@ static Image *ReadOneJNGImage(MngInfo *mng_info,
           exception);
 
         if (status == MagickFalse)
-          return(DestroyImageList(image));
+          {
+            color_image=DestroyImage(color_image);
+            return(DestroyImageList(image));
+          }
 
         if ((image_info->ping == MagickFalse) && (jng_color_type >= 12))
           {
@@ -4403,14 +4406,19 @@ static Image *ReadOneJNGImage(MngInfo *mng_info,
               AcquireMagickMemory(sizeof(ImageInfo));
 
             if (alpha_image_info == (ImageInfo *) NULL)
-              ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
+              {
+                color_image=DestroyImage(color_image);
+                ThrowReaderException(ResourceLimitError,
+                  "MemoryAllocationFailed");
+              }
 
             GetImageInfo(alpha_image_info);
             alpha_image=AcquireImage(alpha_image_info);
 
             if (alpha_image == (Image *) NULL)
               {
-                alpha_image=DestroyImage(alpha_image);
+                alpha_image_info=DestroyImageInfo(alpha_image_info);
+                color_image=DestroyImage(color_image);
                 ThrowReaderException(ResourceLimitError,
                   "MemoryAllocationFailed");
               }
@@ -4425,7 +4433,12 @@ static Image *ReadOneJNGImage(MngInfo *mng_info,
               exception);
 
             if (status == MagickFalse)
-              return(DestroyImageList(image));
+              {
+                alpha_image=DestroyImage(alpha_image);
+                alpha_image_info=DestroyImageInfo(alpha_image_info);
+                color_image=DestroyImage(color_image);
+                return(DestroyImageList(image));
+              }
 
             if (jng_alpha_compression_method == 0)
               {

openSUSE Build Service is sponsored by