File ImageMagick-CVE-2018-16640.patch of Package ImageMagick.28258

diff --git a/coders/png.c b/coders/png.c
index b3ecd890be..d811544e31 100644
--- a/coders/png.c
+++ b/coders/png.c
@@ -4560,7 +4560,11 @@ static Image *ReadOneJNGImage(MngInfo *mng_info,
         chunk=(unsigned char *) AcquireQuantumMemory(length,sizeof(*chunk));
 
         if (chunk == (unsigned char *) NULL)
-          ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
+          {
+            DestroyJNG(NULL,&color_image,&color_image_info,
+              &alpha_image,&alpha_image_info);
+            ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
+          }
 
         for (i=0; i < (ssize_t) length; i++)
         {
openSUSE Build Service is sponsored by