File ImageMagick-png.c-other-fixes.patch of Package ImageMagick.8212

Index: ImageMagick-6.8.8-1/coders/png.c
===================================================================
--- ImageMagick-6.8.8-1.orig/coders/png.c	2018-01-15 08:14:26.478387066 +0100
+++ ImageMagick-6.8.8-1/coders/png.c	2018-01-15 10:16:03.514934017 +0100
@@ -3976,8 +3976,7 @@ static Image *ReadOnePNGImage(MngInfo *m
 static Image *ReadPNGImage(const ImageInfo *image_info,ExceptionInfo *exception)
 {
   Image
-    *image,
-    *previous;
+    *image;
 
   MagickBooleanType
     logging,
@@ -4040,21 +4039,11 @@ static Image *ReadPNGImage(const ImageIn
   (void) ResetMagickMemory(mng_info,0,sizeof(MngInfo));
   mng_info->image=image;
 
-  previous=image;
   image=ReadOnePNGImage(mng_info,image_info,exception);
   mng_info=MngInfoFreeStruct(mng_info);
 
   if (image == (Image *) NULL)
     {
-      if (previous != (Image *) NULL)
-        {
-          if (previous->signature != MagickSignature)
-            ThrowReaderException(CorruptImageError,"CorruptImage");
-
-          (void) CloseBlob(previous);
-          (void) DestroyImageList(previous);
-        }
-
       if (logging != MagickFalse)
         (void) LogMagickEvent(CoderEvent,GetMagickModule(),
           "exit ReadPNGImage() with error");
@@ -4967,8 +4956,7 @@ static Image *ReadOneJNGImage(MngInfo *m
 static Image *ReadJNGImage(const ImageInfo *image_info,ExceptionInfo *exception)
 {
   Image
-    *image,
-    *previous;
+    *image;
 
   MagickBooleanType
     logging,
@@ -5063,8 +5051,7 @@ static Image *ReadOneMNGImage(MngInfo* m
     page_geometry[MaxTextExtent];
 
   Image
-    *image,
-    *previous;
+    *image;
 
   MagickBooleanType
     logging;
@@ -6534,7 +6521,6 @@ static Image *ReadOneMNGImage(MngInfo* m
           ThrowReaderException(CorruptImageError,"ImproperImageHeader");
       }
 
-    previous=image;
     mng_info->image=image;
     mng_info->mng_type=mng_type;
     mng_info->object_id=object_id;
@@ -6549,12 +6535,6 @@ static Image *ReadOneMNGImage(MngInfo* m
 
     if (image == (Image *) NULL)
       {
-        if (IsImageObject(previous) != MagickFalse)
-          {
-            (void) CloseBlob(previous);
-            (void) DestroyImageList(previous);
-          }
-
         return((Image *) NULL);
       }
 
Index: ImageMagick-6.8.8-1/magick/identify.c
===================================================================
--- ImageMagick-6.8.8-1.orig/magick/identify.c	2013-12-01 15:47:50.000000000 +0100
+++ ImageMagick-6.8.8-1/magick/identify.c	2018-01-15 08:35:12.258640335 +0100
@@ -535,7 +535,10 @@ MagickExport MagickBooleanType IdentifyI
         max_locations=StringToUnsignedLong(limit);
       channel_statistics=GetLocationStatistics(image,type,exception);
       if (channel_statistics == (ChannelStatistics *) NULL)
+      {
+        exception=DestroyExceptionInfo(exception);
         return(MagickFalse);
+      }
       colorspace=image->colorspace;
       if (IsGrayImage(image,exception) != MagickFalse)
         colorspace=GRAYColorspace;
@@ -577,6 +580,7 @@ MagickExport MagickBooleanType IdentifyI
           type,max_locations,channel_statistics);
       channel_statistics=(ChannelStatistics *) RelinquishMagickMemory(
         channel_statistics);
+      exception=DestroyExceptionInfo(exception);
       return(ferror(file) != 0 ? MagickFalse : MagickTrue);
     }
   *format='\0';
@@ -649,6 +653,7 @@ MagickExport MagickBooleanType IdentifyI
         floor(elapsed_time))));
       (void) FormatLocaleFile(file,"\n");
       (void) fflush(file);
+      exception=DestroyExceptionInfo(exception);
       return(ferror(file) != 0 ? MagickFalse : MagickTrue);
     }
   /*
@@ -656,6 +661,7 @@ MagickExport MagickBooleanType IdentifyI
   */
   pixels=GetVirtualPixels(image,0,0,1,1,exception);
   exception=DestroyExceptionInfo(exception);
+  exception=(&image->exception);
   ping=pixels == (const PixelPacket *) NULL ? MagickTrue : MagickFalse;
   type=GetImageType(image,&image->exception);
   (void) SignatureImage(image);