]> granicus.if.org Git - imagemagick/commitdiff
https://github.com/ImageMagick/ImageMagick/issues/870
authorCristy <urban-warrior@imagemagick.org>
Mon, 20 Nov 2017 12:46:28 +0000 (07:46 -0500)
committerCristy <urban-warrior@imagemagick.org>
Mon, 20 Nov 2017 12:46:28 +0000 (07:46 -0500)
coders/wpg.c

index d4b58964741a825c0a8ff3199ebcce9adcf45e98..ead3f460d864c82881fcb0552b747ad81106e51c 100644 (file)
@@ -738,6 +738,9 @@ static Image *ExtractPostscript(Image *image,const ImageInfo *image_info,
   FILE
     *ps_file;
 
+  int
+    c;
+
   ImageInfo
     *clone_info;
     
@@ -764,10 +767,13 @@ static Image *ExtractPostscript(Image *image,const ImageInfo *image_info,
   (void) ReadBlob(image, 2*MagickPathExtent, magick);
   
   (void) SeekBlob(image,PS_Offset,SEEK_SET);
-  while(PS_Size-- > 0)
-    {
-      (void) fputc(ReadBlobByte(image),ps_file);
-    }
+  while (PS_Size-- > 0)
+  {
+    c=ReadBlobByte(image);
+    if (c == EOF)
+      break;
+    (void) fputc(c,ps_file);
+  }
   (void) fclose(ps_file);
   
     /* Detect file format - Check magic.mgk configuration file. */