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

Index: ImageMagick-6.8.8-1/coders/msl.c
===================================================================
--- ImageMagick-6.8.8-1.orig/coders/msl.c	2018-02-16 19:33:38.901149229 +0100
+++ ImageMagick-6.8.8-1/coders/msl.c	2018-02-16 19:35:38.783113094 +0100
@@ -594,6 +594,8 @@ static void MSLPopImage(MSLInfo *msl_inf
     msl_info->image[msl_info->n]=DestroyImage(msl_info->image[msl_info->n]);
   msl_info->attributes[msl_info->n]=DestroyImage(
     msl_info->attributes[msl_info->n]);
+  msl_info->draw_info[msl_info->n]=DestroyDrawInfo(
+    msl_info->draw_info[msl_info->n]);
   msl_info->image_info[msl_info->n]=DestroyImageInfo(
     msl_info->image_info[msl_info->n]);
   msl_info->n--;
@@ -7843,18 +7845,24 @@ static MagickBooleanType ProcessMSLScrip
   */
   xmlFreeParserCtxt(msl_info.parser);
   (void) LogMagickEvent(CoderEvent,GetMagickModule(),"end SAX");
-  msl_info.group_info=(MSLGroupInfo *) RelinquishMagickMemory(
-    msl_info.group_info);
   if (*image == (Image *) NULL)
-    *image=(*msl_info.image);
-  *msl_info.image_info=DestroyImageInfo(*msl_info.image_info);
-  msl_info.image_info=(ImageInfo **) RelinquishMagickMemory(
-    msl_info.image_info);
-  *msl_info.draw_info=DestroyDrawInfo(*msl_info.draw_info);
+    *image=CloneImage(*msl_info.image,0,0,MagickTrue,exception);
+  while (msl_info.n >= 0)
+  {
+    msl_info.image[msl_info.n]=DestroyImage(msl_info.image[msl_info.n]);
+    msl_info.attributes[msl_info.n]=DestroyImage(
+      msl_info.attributes[msl_info.n]);
+    msl_info.draw_info[msl_info.n]=DestroyDrawInfo(
+      msl_info.draw_info[msl_info.n]);
+    msl_info.image_info[msl_info.n]=DestroyImageInfo(
+      msl_info.image_info[msl_info.n]);
+    msl_info.n--;
+  } 
   msl_info.draw_info=(DrawInfo **) RelinquishMagickMemory(msl_info.draw_info);
   msl_info.image=(Image **) RelinquishMagickMemory(msl_info.image);
-  *msl_info.attributes=DestroyImage(*msl_info.attributes);
   msl_info.attributes=(Image **) RelinquishMagickMemory(msl_info.attributes);
+  msl_info.image_info=(ImageInfo **) RelinquishMagickMemory(
+    msl_info.image_info);
   msl_info.group_info=(MSLGroupInfo *) RelinquishMagickMemory(
     msl_info.group_info);
   if ((*msl_info.image)->exception.severity != UndefinedException)
@@ -8274,9 +8282,6 @@ static MagickBooleanType WriteMSLImage(c
   Image
     *msl_image;
 
-  MagickBooleanType
-    status;
-
   assert(image_info != (const ImageInfo *) NULL);
   assert(image_info->signature == MagickSignature);
   assert(image != (Image *) NULL);
@@ -8284,9 +8289,6 @@ static MagickBooleanType WriteMSLImage(c
   if (image->debug != MagickFalse)
     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
   msl_image=CloneImage(image,0,0,MagickTrue,&image->exception);
-  status=ProcessMSLScript(image_info,&msl_image,&image->exception);
-  if (msl_image)
-    msl_image=DestroyImage(msl_image);
-  return(status);
+  return(ProcessMSLScript(image_info,&msl_image,&image->exception));
 }
 #endif