]> granicus.if.org Git - imagemagick/commitdiff
...
authorCristy <urban-warrior@imagemagick.org>
Wed, 10 Jan 2018 14:19:55 +0000 (09:19 -0500)
committerCristy <urban-warrior@imagemagick.org>
Wed, 10 Jan 2018 14:19:55 +0000 (09:19 -0500)
coders/wpg.c

index 82bd9eaa8c16fd2a3a84691d54cb7589f9555d24..56f96d3df4bc2e9088054dffc9241a97cce9075c 100644 (file)
@@ -796,22 +796,54 @@ static Image *ExtractPostscript(Image *image,const ImageInfo *image_info,
 
   if (!image2)
     goto FINISH_UNL;
+  if(exception->severity>=ErrorException)
+  {
+    CloseBlob(image2);
+    DestroyImageList(image2); 
+    goto FINISH_UNL;
+  }
 
-  /*
-    Replace current image with new image while copying base image
-    attributes.
-  */
-  (void) CopyMagickString(image2->filename,image->filename,MagickPathExtent);
-  (void) CopyMagickString(image2->magick_filename,image->magick_filename,MagickPathExtent);
-  (void) CopyMagickString(image2->magick,image->magick,MagickPathExtent);
-  image2->depth=image->depth;
-  DestroyBlob(image2);
-  image2->blob=ReferenceBlob(image->blob);
-
-  if ((image->rows == 0) || (image->columns == 0))
+  {
+    Image
+      *p;
+
+    /*
+      Replace current image with new image while copying base image attributes.
+    */
+    p=image2;
+    do
+    {
+      (void) CopyMagickString(p->filename,image->filename,MagickPathExtent);
+      (void) CopyMagickString(p->magick_filename,image->magick_filename,
+        MagickPathExtent);
+      (void) CopyMagickString(p->magick,image->magick,MagickPathExtent);
+      DestroyBlob(p);
+      if ((p->rows == 0) || (p->columns == 0))
+        {
+          DeleteImageFromList(&p);
+          if (p == (Image *) NULL)
+            {
+              image2=(Image *) NULL;
+              goto FINISH_UNL;
+            }
+        }
+      else 
+        {
+          p->blob=ReferenceBlob(image->blob);
+          p=p->next;
+        }
+    } while (p != (Image *) NULL);
+  }
+
+  if ((image->rows == 0 || image->columns == 0) &&
+      (image->previous != NULL || image->next != NULL))
+  {
     DeleteImageFromList(&image);
+  }
 
   AppendImageToList(&image,image2);
+  while (image->next != NULL)
+    image=image->next;
 
  FINISH_UNL:
   (void) RelinquishUniqueFileResource(postscript_file);