From 06c8dd4de59e48d282d4f224faa64ab9012a711a Mon Sep 17 00:00:00 2001 From: Cristy Date: Mon, 20 Nov 2017 07:46:28 -0500 Subject: [PATCH] https://github.com/ImageMagick/ImageMagick/issues/870 --- coders/wpg.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/coders/wpg.c b/coders/wpg.c index d4b589647..ead3f460d 100644 --- a/coders/wpg.c +++ b/coders/wpg.c @@ -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. */ -- 2.40.0