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

Index: ImageMagick-6.8.8-1/coders/pcx.c
===================================================================
--- ImageMagick-6.8.8-1.orig/coders/pcx.c	2018-02-06 10:19:57.204779125 +0100
+++ ImageMagick-6.8.8-1/coders/pcx.c	2018-02-06 10:20:34.005369295 +0100
@@ -372,6 +372,8 @@ static Image *ReadPCXImage(const ImageIn
     count=ReadBlob(image,3*image->colors,pcx_colormap);
     pcx_info.reserved=(unsigned char) ReadBlobByte(image);
     pcx_info.planes=(unsigned char) ReadBlobByte(image);
+    if (pcx_info.planes > 6)
+      ThrowPCXException(CorruptImageError,"ImproperImageHeader");
     one=1;
     if ((pcx_info.bits_per_pixel != 8) || (pcx_info.planes == 1))
       if ((pcx_info.version == 3) || (pcx_info.version == 5) ||
Index: ImageMagick-6.8.8-1/magick/memory.c
===================================================================
--- ImageMagick-6.8.8-1.orig/magick/memory.c	2018-02-06 10:19:57.204779125 +0100
+++ ImageMagick-6.8.8-1/magick/memory.c	2018-02-06 10:21:31.090285097 +0100
@@ -630,11 +630,12 @@ MagickExport MemoryInfo *AcquireVirtualM
           (void) close(file);
         }
     }
-  if (memory_info->blob == NULL)
+  if ((memory_info->blob == NULL) && (AcquireMagickResource(MemoryResource,length) != MagickFalse))
     {
       memory_info->blob=AcquireMagickMemory(length);
       if (memory_info->blob != NULL)
         memory_info->type=UnalignedVirtualMemory;
+       RelinquishMagickResource(MemoryResource,length);
     }
   if (memory_info->blob == NULL)
     memory_info=RelinquishVirtualMemory(memory_info);