]> granicus.if.org Git - imagemagick/commitdiff
Eliminate possible but rare memory leak (bug report by Dirk)
authorCristy <urban-warrior@imagemagick.org>
Fri, 17 Mar 2017 11:14:25 +0000 (07:14 -0400)
committerCristy <urban-warrior@imagemagick.org>
Fri, 17 Mar 2017 11:14:25 +0000 (07:14 -0400)
coders/pgx.c

index e03981f879c6650d5bb8738b6e68186b4a599411..04a5f2c99624b1635da3ce0fdbcc6db6ae5e8deb 100644 (file)
@@ -376,7 +376,7 @@ static MagickBooleanType WritePGXImage(const ImageInfo *image_info,Image *image,
       GrayQuantum,pixels,exception);
     count=WriteBlob(image,length,pixels);
     if (count != (ssize_t) length)
-      ThrowWriterException(CorruptImageError,"UnableToWriteImageData");
+      break;
     count=WriteBlob(image,(size_t) (-(ssize_t) length) & 0x01,pixels);
     status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y,
       image->rows);
@@ -384,6 +384,8 @@ static MagickBooleanType WritePGXImage(const ImageInfo *image_info,Image *image,
       break;
   }
   quantum_info=DestroyQuantumInfo(quantum_info);
+  if (y < (ssize_t) image->rows)
+    ThrowWriterException(CorruptImageError,"UnableToWriteImageData");
   (void) CloseBlob(image);
   return(status);
 }