File ImageMagick-CVE-2014-9849.patch of Package ImageMagick.8212

Index: ImageMagick-6.8.8-1/coders/png.c
===================================================================
--- ImageMagick-6.8.8-1.orig/coders/png.c	2013-12-22 03:08:38.000000000 +0100
+++ ImageMagick-6.8.8-1/coders/png.c	2016-06-13 13:23:33.256685818 +0200
@@ -3215,6 +3215,16 @@ static Image *ReadOnePNGImage(MngInfo *m
 
   if (image->storage_class == DirectClass)
     {
+      QuantumInfo
+        *quantum_info;
+
+      quantum_info=AcquireQuantumInfo(image_info,image);
+
+      if (quantum_info == (QuantumInfo *) NULL)
+        png_error(ping,"Failed to allocate quantum_info");
+
+      (void) SetQuantumEndian(image,quantum_info,MSBEndian);
+
       for (pass=0; pass < num_passes; pass++)
       {
         /*
@@ -3246,16 +3256,6 @@ static Image *ReadOnePNGImage(MngInfo *m
 
           else
           {
-            QuantumInfo
-              *quantum_info;
-
-            quantum_info=AcquireQuantumInfo(image_info,image);
-
-            if (quantum_info == (QuantumInfo *) NULL)
-              png_error(ping,"Failed to allocate quantum_info");
-
-            (void) SetQuantumEndian(image,quantum_info,MSBEndian);
-
             if ((int) ping_color_type == PNG_COLOR_TYPE_GRAY)
               (void) ImportQuantumPixels(image,(CacheView *) NULL,quantum_info,
                 GrayQuantum,ping_pixels+row_offset,exception);
@@ -3276,7 +3276,6 @@ static Image *ReadOnePNGImage(MngInfo *m
               (void) ImportQuantumPixels(image,(CacheView *) NULL,quantum_info,
                 RGBQuantum,ping_pixels+row_offset,exception);
 
-            quantum_info=DestroyQuantumInfo(quantum_info);
           }
 
           if (found_transparent_pixel == MagickFalse)
@@ -3337,6 +3336,7 @@ static Image *ReadOnePNGImage(MngInfo *m
               break;
           }
       }
+      quantum_info=DestroyQuantumInfo(quantum_info);
     }
 
   else /* image->storage_class != DirectClass */