File ImageMagick-CVE-2017-9142.patch of Package ImageMagick.8212

Index: ImageMagick-6.8.8-1/coders/png.c
===================================================================
--- ImageMagick-6.8.8-1.orig/coders/png.c	2017-05-30 13:19:34.860250352 +0200
+++ ImageMagick-6.8.8-1/coders/png.c	2017-05-30 13:19:49.424503811 +0200
@@ -4443,10 +4443,11 @@ static Image *ReadOneJNGImage(MngInfo *m
           (void) LogMagickEvent(CoderEvent,GetMagickModule(),
             "    Copying JDAT chunk data to color_blob.");
 
-        (void) WriteBlob(color_image,length,chunk);
-
-        if (length)
-          chunk=(unsigned char *) RelinquishMagickMemory(chunk);
+        if (length != 0)
+          {
+            (void) WriteBlob(color_image,length,chunk);
+            chunk=(unsigned char *) RelinquishMagickMemory(chunk);
+          }
 
         continue;
       }