File GraphicsMagick-CVE-2017-12662.patch of Package GraphicsMagick.7893

From 73a2bad43d157acfe360595feee739b4cc4406cb Mon Sep 17 00:00:00 2001
From: Cristy <urban-warrior@imagemagick.org>
Date: Mon, 17 Jul 2017 19:17:50 -0400
Subject: [PATCH] https://github.com/ImageMagick/ImageMagick/issues/576

---
 coders/pdf.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

Index: GraphicsMagick-1.2.5/coders/pdf.c
===================================================================
--- GraphicsMagick-1.2.5.orig/coders/pdf.c	2017-12-05 13:15:27.085076002 +0100
+++ GraphicsMagick-1.2.5/coders/pdf.c	2017-12-05 13:23:41.245491904 +0100
@@ -1210,8 +1210,11 @@ static unsigned int WritePDFImage(const
                 length=number_pixels;
                 pixels=MagickAllocateMemory(unsigned char *,length);
                 if (pixels == (unsigned char *) NULL)
+                {
+                  MagickFreeMemory(xref);
                   ThrowWriterException(ResourceLimitError,MemoryAllocationFailed,
                                        image);
+                }
                 /*
                   Dump Runlength encoded pixels.
                 */
@@ -1325,8 +1328,11 @@ static unsigned int WritePDFImage(const
                 length=(image->colorspace == CMYKColorspace ? 4 : 3)*number_pixels;
                 pixels=MagickAllocateMemory(unsigned char *,length);
                 if (pixels == (unsigned char *) NULL)
+                {
+                  MagickFreeMemory(xref);
                   ThrowWriterException(ResourceLimitError,MemoryAllocationFailed,
                                        image);
+                }
                 /*
                   Dump runoffset encoded pixels.
                 */
@@ -1437,7 +1443,10 @@ static unsigned int WritePDFImage(const
                   length=number_pixels;
                   pixels=MagickAllocateMemory(unsigned char *,length);
                   if (pixels == (unsigned char *) NULL)
+                  {
+                    MagickFreeMemory(xref);
                     ThrowWriterException(ResourceLimitError,MemoryAllocationFailed,image);
+                  }
                   /*
                     Dump Runlength encoded pixels.
                   */
openSUSE Build Service is sponsored by