GraphicsMagick: Added MagickReallocStd(). Fix potential ExpandF...

GraphicsMagick Commits <[email protected]> Sun, 05 Nov 2023 14:13:11 -0600
Newsgroups gmane.comp.video.graphicsmagick.cvs
Message-ID <mailman.14689.1699215205.7975.graphicsmagick-commit@lists.sourceforge.net>
changeset a2df49f69acd in /hg/GraphicsMagick
details: http://hg.GraphicsMagick.org/hg/GraphicsMagick?cmd=changeset;node=a2df49f69acd
summary: Added MagickReallocStd().  Fix potential ExpandFilenames() leak.  BMP, FITS, WPG fixes.

diffstat:

 ChangeLog                              |   43 ++++++++++-
 Makefile.in                            |    4 +-
 PerlMagick/Magick.xs                   |    4 +-
 PerlMagick/Makefile.am                 |    4 +-
 PerlMagick/README.txt                  |   25 +++--
 PerlMagick/t/png/read.t                |    2 +-
 PerlMagick/t/read.t                    |   24 ++++--
 PerlMagick/t/subroutines.pl            |    6 +-
 VisualMagick/installer/inc/version.isx |    4 +-
 coders/bmp.c                           |   11 +-
 coders/fits.c                          |    4 +-
 coders/wpg.c                           |  128 +++++++++++++++-----------------
 magick/list.c                          |    9 +-
 magick/memory-private.h                |    1 -
 magick/memory.c                        |   53 +++++++++++++-
 magick/memory.h                        |   12 +-
 magick/symbols.h                       |    3 +-
 magick/utility.c                       |   33 ++++++--
 magick/version.h                       |    4 +-
 www/Changelog.html                     |   44 +++++++++++
 www/api/list.html                      |    3 +-
 www/api/memory.html                    |   74 +++++++++++++-----
 22 files changed, 345 insertions(+), 150 deletions(-)

diffs (truncated from 1149 to 500 lines):

diff -r fe0204d51af0 -r a2df49f69acd ChangeLog
--- a/ChangeLog	Sun Nov 05 20:54:08 2023 +0100
+++ b/ChangeLog	Sun Nov 05 14:13:06 2023 -0600
@@ -1,8 +1,45 @@
+2023-11-05  Bob Friesenhahn  <[email protected]>
+
+	* magick/utility.c (ExpandFilenames): Fix memory leak of existing
+	allocations if realloc() fails.
+
+	* magick/memory.c (MagickReallocStd): Added function to expose
+	standard realloc() functionality to allow cleanup of original
+	object.
+
+	* magick/list.c (AppendImageToList): Added image could itself be a
+	list, so seek again for the end of the list.
+	(GetImageListLength): Count value should be unsigned long.
+
+	* coders/wpg.c (ReadWPGImage): Reset image rows and columns to
+	zero.
+	(ExtractPostscript): Pass original image pointer storage.
+
+	* coders/fits.c (ReadFITSImage): Reset image rows and columns to
+	zero.
+
+	* coders/bmp.c (ExtractNestedBlob): Reset image rows and columns
+	to zero.
+
+	* PerlMagick/t/subroutines.pl (testRead): Remove request for size
+	512x512.
+
+	* PerlMagick/t/read.t: Fix checksums for FITS tests.
+
+	* PerlMagick/t/png/read.t: Fix checksum for PNG in BMP format.
+
+	* PerlMagick/Makefile.am (perl-check): Enable verbose PerlMagick
+	tests using TEST_VERBOSE=1.
+
 2023-11-05  Fojtik Jaroslav  <[email protected]>
 
-	PerlMagick/t/input1_PS.wpg
-	PerlMagick/t/input1_PS.wpg Add 2 samples of WPG that really contains
-	embedded EPS.
+	PerlMagick/t/input1_PS.wpg PerlMagick/t/input2_PS.wpg Add 2
+	samples of WPG that really contain embedded EPS.
+
+2023-11-04  Bob Friesenhahn  <[email protected]>
+
+	* coders/bmp.c (ExtractNestedBlob): Always need to remove image
+	which is being replaced.
 
 2023-10-21  Fojtik Jaroslav  <[email protected]>
 
diff -r fe0204d51af0 -r a2df49f69acd Makefile.in
--- a/Makefile.in	Sun Nov 05 20:54:08 2023 +0100
+++ b/Makefile.in	Sun Nov 05 14:13:06 2023 -0600
@@ -11307,7 +11307,7 @@
 @WITH_PERL_DYNAMIC_TRUE@@WITH_PERL_TRUE@	( cd $(PERLMAGICK) && $(MAKE) CC='@CC@' )
 
 @WITH_PERL_DYNAMIC_TRUE@@WITH_PERL_TRUE@perl-check: $(PERLMAKEFILE)
-@WITH_PERL_DYNAMIC_TRUE@@WITH_PERL_TRUE@	cd $(PERLMAGICK) && $(abs_top_builddir)/rungm.sh $(MAKE) CC='@CC@' test
+@WITH_PERL_DYNAMIC_TRUE@@WITH_PERL_TRUE@	cd $(PERLMAGICK) && $(abs_top_builddir)/rungm.sh $(MAKE) CC='@CC@' test TEST_VERBOSE=1
 
 @WITH_PERL_DYNAMIC_TRUE@@WITH_PERL_TRUE@check-perl:
 
@@ -11337,7 +11337,7 @@
 @WITH_PERL_DYNAMIC_FALSE@@WITH_PERL_STATIC_TRUE@@WITH_PERL_TRUE@	rm -f '$(DESTDIR)$(BIN_DIR)/$(PERLSTATICNAME)'
 
 @WITH_PERL_DYNAMIC_FALSE@@WITH_PERL_STATIC_TRUE@@WITH_PERL_TRUE@check-perl: $(PERLMAGICK)/$(PERLSTATICNAME)
-@WITH_PERL_DYNAMIC_FALSE@@WITH_PERL_STATIC_TRUE@@WITH_PERL_TRUE@	cd $(PERLMAGICK) && $(abs_top_builddir)/rungm.sh $(MAKE) -f Makefile.aperl CC='@CC@' test
+@WITH_PERL_DYNAMIC_FALSE@@WITH_PERL_STATIC_TRUE@@WITH_PERL_TRUE@	cd $(PERLMAGICK) && $(abs_top_builddir)/rungm.sh $(MAKE) -f Makefile.aperl CC='@CC@' test TEST_VERBOSE=1
 
 @WITH_PERL_DYNAMIC_FALSE@@WITH_PERL_STATIC_TRUE@@WITH_PERL_TRUE@perl-build: $(PERLMAGICK)/$(PERLSTATICNAME)
 
diff -r fe0204d51af0 -r a2df49f69acd PerlMagick/Magick.xs
--- a/PerlMagick/Magick.xs	Sun Nov 05 20:54:08 2023 +0100
+++ b/PerlMagick/Magick.xs	Sun Nov 05 14:13:06 2023 -0600
@@ -7679,12 +7679,14 @@
     MY_CXT.error_jump=(&error_jmp);
     if (setjmp(error_jmp))
       goto ReturnIt;
-    status=ExpandFilenames(&n,&list);
+#if 1
+    status=ExpandFilenames(&n,&list); /* FIXME: Leaks original 16-byte list allocation! */
     if (status == False)
       {
         MagickError(ResourceLimitError,MemoryAllocationFailed,NULL);
         goto ReturnIt;
       }
+#endif
     GetExceptionInfo(&exception);
     number_images=0;
     for (i=0; i < n; i++)
diff -r fe0204d51af0 -r a2df49f69acd PerlMagick/Makefile.am
--- a/PerlMagick/Makefile.am	Sun Nov 05 20:54:08 2023 +0100
+++ b/PerlMagick/Makefile.am	Sun Nov 05 14:13:06 2023 -0600
@@ -79,7 +79,7 @@
 	( cd $(PERLMAGICK) && $(MAKE) CC='@CC@' )
 
 perl-check: $(PERLMAKEFILE)
-	cd $(PERLMAGICK) && $(abs_top_builddir)/rungm.sh $(MAKE) CC='@CC@' test
+	cd $(PERLMAGICK) && $(abs_top_builddir)/rungm.sh $(MAKE) CC='@CC@' test TEST_VERBOSE=1
 
 check-perl:
 
@@ -118,7 +118,7 @@
 	rm -f '$(DESTDIR)$(BIN_DIR)/$(PERLSTATICNAME)'
 
 check-perl: $(PERLMAGICK)/$(PERLSTATICNAME)
-	cd $(PERLMAGICK) && $(abs_top_builddir)/rungm.sh $(MAKE) -f Makefile.aperl CC='@CC@' test
+	cd $(PERLMAGICK) && $(abs_top_builddir)/rungm.sh $(MAKE) -f Makefile.aperl CC='@CC@' test TEST_VERBOSE=1
 
 perl-build: $(PERLMAGICK)/$(PERLSTATICNAME)
 
diff -r fe0204d51af0 -r a2df49f69acd PerlMagick/README.txt
--- a/PerlMagick/README.txt	Sun Nov 05 20:54:08 2023 +0100
+++ b/PerlMagick/README.txt	Sun Nov 05 14:13:06 2023 -0600
@@ -7,7 +7,7 @@
 # package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
 ===========================================================================
 
-Introduction 
+Introduction
 
     PerlMagick, is an objected-oriented Perl interface to GraphicsMagick.
     Use the module to read, manipulate, or write an image or image
@@ -26,7 +26,7 @@
     for instructions about installing GraphicsMagick.
 
 
-Installation 
+Installation
 
     PerlMagick is configured by default by GraphicsMagick in order to
     create a starting Makefile.PL.  Additional edits to Makefile.PL
@@ -35,7 +35,7 @@
     described here in order to complete the installation of
     PerlMagick.
 
-    Get the GraphicsMagick distribution and type the following: 
+    Get the GraphicsMagick distribution and type the following:
 
         gunzip -c GraphicsMagick-1.2.tar.gz | tar -xvf -
         cd GraphicsMagick
@@ -59,7 +59,7 @@
 
     To create and install the dymamically-loaded version of
     PerlMagick (the preferred way), execute
-        
+
         perl Makefile.PL
         make
         su root (if necessary)
@@ -76,13 +76,13 @@
         perl Makefile.PL
         make perl
         make -f Makefile.aperl inst_perl
-	
+
     or to create and install a new PERL interpreter with a
     different name than 'perl' (e.g. 'PerlMagick') and with
     PerlMagick statically linked
 
         perl Makefile.PL MAP_TARGET=PerlMagick
-	make PerlMagick
+        make PerlMagick
         make -f Makefile.aperl inst_perl
 
     See the ExtUtils::MakeMaker(3) manual page for more information on
@@ -102,7 +102,7 @@
 Testing PerlMagick
 
     Before PerlMagick is installed, you may want to execute
-    
+
         make test
 
     to verify that PERL can load the PerlMagick extension ok.  Chances
@@ -112,15 +112,20 @@
     is advised not to install PerlMagick until the problem is
     resolved.
 
+    The 'prove' utility may be used to execute a test from the
+    PerlMagick build directory like
+
+        prove --blib blib -I `pwd` -bv ./t/read.t
+
     To see a number of PerlMagick demonstration scripts, type
-    
+
         cd demo
         make
 
 
-Example Perl Magick Script 
+Example Perl Magick Script
 
-    Here is an example script to get you started: 
+    Here is an example script to get you started:
 
         #!/usr/bin/perl
         use Graphics::Magick;
diff -r fe0204d51af0 -r a2df49f69acd PerlMagick/t/png/read.t
--- a/PerlMagick/t/png/read.t	Sun Nov 05 20:54:08 2023 +0100
+++ b/PerlMagick/t/png/read.t	Sun Nov 05 14:13:06 2023 -0600
@@ -77,5 +77,5 @@
 # of multiple frames from the BMP reader!
 ++$test;
 print( "PNG in BMP format ...\n" );
-testRead( 'input_PNG.bmp[1]', q//,
+testRead( 'input_PNG.bmp', q//,
   '88956c2242aab1c8f23d4074ed4f313316413cf79ccf1fea8f650f30bd8e2e42' );
diff -r fe0204d51af0 -r a2df49f69acd PerlMagick/t/read.t
--- a/PerlMagick/t/read.t	Sun Nov 05 20:54:08 2023 +0100
+++ b/PerlMagick/t/read.t	Sun Nov 05 14:13:06 2023 -0600
@@ -1,5 +1,5 @@
 #!/usr/local/bin/perl
-# Copyright (C) 2003-2022 GraphicsMagick Group
+# Copyright (C) 2003-2023 GraphicsMagick Group
 # Copyright (C) 2002 ImageMagick Studio
 # Copyright (C) 1991-1999 E. I. du Pont de Nemours and Company
 #
@@ -60,19 +60,22 @@
 
 print("Flexible Image Transport System 8-bit ...\n");
 ++$test;
-testReadCompare('input_gray_08bit.fits', 'reference/read/input_gray_08bit_fits.miff', q//, 0, 0);
+#testReadCompare('input_gray_08bit.fits', 'reference/read/input_gray_08bit_fits.miff', q//, 0, 0);
 # This one produces a different signature each time!
-#testRead('input_gray_08bit.fits', q//,, ,'863a70f43cb481512e805babd7e09360ef6e5c7fe75725712242b367f0d0ef28');
+testRead('input_gray_08bit.fits', q//,, ,'863a70f43cb481512e805babd7e09360ef6e5c7fe75725712242b367f0d0ef28');
 
 print("Flexible Image Transport System LSB 16-bit ...\n");
 ++$test;
 testRead('input_gray_16bit.fits',  q//,
-         'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855');
+         'acfbc25e7afd4b80db3e961fe4432cc9acab0d8f599728593ee950cb9099b10e',
+         'ee9617706ce2af8c4f40536d6e0f17626c5b080f5af4ed7a05f72445fb9dd3ca');
 
 print("Flexible Image Transport System LSB 32-bit ...\n");
 ++$test;
 testRead('input_gray_32bit.fits', q//,
-         'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855');
+         'fb49d38988edb04b20bfa89c5e16378c3e18c559716194f2c9c712f8f232b11f',
+         '33fe0fb5e1dc38f8b74dce16a854a54bd2ea33052bf73ced9736ee86f3e6d0a8',
+         'b46acb2a1e91421d06f3c2a094f3e31eaa304721dba57890472c822b14da4abc');
 
 print("Flexible Image Transport System LSB double ...\n");
 ++$test;
@@ -81,17 +84,22 @@
 print("Flexible Image Transport System MSB 16-bit ...\n");
 ++$test;
 testRead('input_gray_msb_16bit.fits', q//,
-         'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855');
+         'acfbc25e7afd4b80db3e961fe4432cc9acab0d8f599728593ee950cb9099b10e',
+         'ee9617706ce2af8c4f40536d6e0f17626c5b080f5af4ed7a05f72445fb9dd3ca');
 
 print("Flexible Image Transport System MSB 32-bit ...\n");
 ++$test;
 testRead('input_gray_msb_32bit.fits', q//,
-         'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855');
+         'fb49d38988edb04b20bfa89c5e16378c3e18c559716194f2c9c712f8f232b11f',
+         '33fe0fb5e1dc38f8b74dce16a854a54bd2ea33052bf73ced9736ee86f3e6d0a8',
+         'b46acb2a1e91421d06f3c2a094f3e31eaa304721dba57890472c822b14da4abc');
 
 print("Flexible Image Transport System MSB 64-bit ...\n");
 ++$test;
 testRead('input_gray_msb_64bit.fits', q//,
-         'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855');
+         '96bb41e5cb2053972958b7cc8293a2ee5f7d72920479cf586358d3364747d137',
+         'ab8c63ef21f01a4f94b757909a918cbb154f039b658816731c927003bf49eca5',
+         '4dcd8bb105383a45eb803a213f354af6655b5bad4d3e8a9c7355c28b2d5b738a');
 
 print("Flexible Image Transport System MSB float ...\n");
 ++$test;
diff -r fe0204d51af0 -r a2df49f69acd PerlMagick/t/subroutines.pl
--- a/PerlMagick/t/subroutines.pl	Sun Nov 05 20:54:08 2023 +0100
+++ b/PerlMagick/t/subroutines.pl	Sun Nov 05 14:13:06 2023 -0600
@@ -1,4 +1,4 @@
-# Copyright (C) 2003-2016 GraphicsMagick Group
+# Copyright (C) 2003-2023 GraphicsMagick Group
 # Copyright (C) 2002 ImageMagick Studio
 # Copyright (C) 1999 E. I. du Pont de Nemours and Company
 #
@@ -238,7 +238,7 @@
 
     print( "  testing reading from file \"", $infile, "\" ...\n");
     $image=Graphics::Magick->new;
-    $image->Set(size=>'512x512');
+    #$image->Set(size=>'512x512');
 
     if ( "$read_options" ne "" ) {
         eval "\$status=\$image->Set($read_options);";
@@ -290,7 +290,7 @@
         close( FILE );
         if( defined( $blob ) ) {
           $image=Graphics::Magick->new(magick=>$magick);
-          $image->Set(size=>'512x512');
+          #$image->Set(size=>'512x512');
 
           if ( defined( $read_options ) && "$read_options" ne "" ) {
               eval "\$status=\$image->Set($read_options);";
diff -r fe0204d51af0 -r a2df49f69acd VisualMagick/installer/inc/version.isx
--- a/VisualMagick/installer/inc/version.isx	Sun Nov 05 20:54:08 2023 +0100
+++ b/VisualMagick/installer/inc/version.isx	Sun Nov 05 14:13:06 2023 -0600
@@ -10,5 +10,5 @@
 
 #define public MagickPackageName "GraphicsMagick"
 #define public MagickPackageVersion "1.4"
-#define public MagickPackageVersionAddendum ".020231022"
-#define public MagickPackageReleaseDate "snapshot-20231022"
+#define public MagickPackageVersionAddendum ".020231105"
+#define public MagickPackageReleaseDate "snapshot-20231105"
diff -r fe0204d51af0 -r a2df49f69acd coders/bmp.c
--- a/coders/bmp.c	Sun Nov 05 20:54:08 2023 +0100
+++ b/coders/bmp.c	Sun Nov 05 14:13:06 2023 -0600
@@ -578,6 +578,10 @@
           if ((image2 = BlobToImage(clone_info,blob,alloc_size,exception))
               != NULL)
             {
+              if ((*image)->logging)
+                (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                      "Read embedded %s blob with dimensions %lux%lu",
+                                      image2->magick, image2->rows, image2->columns);
               /*
                 Replace current image with new image while copying
                 base image attributes.
@@ -590,10 +594,7 @@
                            sizeof(image2->magick));
             DestroyBlob(image2);
             image2->blob = ReferenceBlob((*image)->blob);
-
-            if (((*image)->rows == 0) || ((*image)->columns == 0))
-              DeleteImageFromList(image);
-
+            DeleteImageFromList(image);
             AppendImageToList(image, image2);
          }
           DestroyImageInfo(clone_info);
@@ -721,6 +722,8 @@
   pixels=(unsigned char *) NULL;
   logging=LogMagickEvent(CoderEvent,GetMagickModule(),"enter");
   image=AllocateImage(image_info);
+  image->rows=0;
+  image->columns=0;
   status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
   if (status == False)
     ThrowBMPReaderException(FileOpenError,UnableToOpenFile,image);
diff -r fe0204d51af0 -r a2df49f69acd coders/fits.c
--- a/coders/fits.c	Sun Nov 05 20:54:08 2023 +0100
+++ b/coders/fits.c	Sun Nov 05 14:13:06 2023 -0600
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003 - 2022 GraphicsMagick Group
+% Copyright (C) 2003 - 2023 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 % Copyright 1991-1999 E. I. du Pont de Nemours and Company
 %
@@ -221,6 +221,8 @@
   logging = LogMagickEvent(CoderEvent,GetMagickModule(),"enter");
 
   image=AllocateImage(image_info);
+  image->rows=0;
+  image->columns=0;
   status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
   if (status == False)
     ThrowReaderException(FileOpenError,UnableToOpenFile,image);
diff -r fe0204d51af0 -r a2df49f69acd coders/wpg.c
--- a/coders/wpg.c	Sun Nov 05 20:54:08 2023 +0100
+++ b/coders/wpg.c	Sun Nov 05 14:13:06 2023 -0600
@@ -798,7 +798,7 @@
 }
 
 
-static Image *ExtractPostscript(Image *image,const ImageInfo *image_info,
+static Image *ExtractPostscript(Image **image,const ImageInfo *image_info,
                                 ExtendedSignedIntegralType PS_Offset,
                                 size_t PS_Size,ExceptionInfo *exception)
 {
@@ -824,7 +824,7 @@
   magick_off_t
     filesize;
 
-  if (image->logging)
+  if ((*image)->logging)
     (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                           "ExtractPostscript(): PS_Offset=%"MAGICK_OFF_F"d, PS_Size=%"MAGICK_SIZE_T_F"u",
                           (magick_off_t) PS_Offset, (MAGICK_SIZE_T) PS_Size);
@@ -832,30 +832,30 @@
   /*
     Validate that claimed subordinate image data is contained in file size
   */
-  filesize = GetBlobSize(image);
+  filesize = GetBlobSize((*image));
   if ((PS_Offset > filesize) || ((size_t) (filesize - PS_Offset) < PS_Size))
     {
-      if (image->logging)
+      if ((*image)->logging)
         (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                               "ExtractPostscript(): Failed to seek to PS_Offset=%"MAGICK_OFF_F"d",
                               (magick_off_t) PS_Offset);
-      ThrowException(exception,CorruptImageError,UnexpectedEndOfFile,image->filename);
-      return image;
+      ThrowException(exception,CorruptImageError,UnexpectedEndOfFile,(*image)->filename);
+      return *image;
     }
 
   /*
     Get subordinate file header magick and use it to identify file format
   */
-  if (SeekBlob(image,PS_Offset,SEEK_SET) != PS_Offset)
+  if (SeekBlob((*image),PS_Offset,SEEK_SET) != PS_Offset)
     {
-      if (image->logging)
+      if ((*image)->logging)
         (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                               "ExtractPostscript(): Failed to seek to PS_Offset=%"MAGICK_OFF_F"d",
                               (magick_off_t) PS_Offset);
-      ThrowException(exception,CorruptImageError,UnexpectedEndOfFile,image->filename);
-      return image;
+      ThrowException(exception,CorruptImageError,UnexpectedEndOfFile,(*image)->filename);
+      return *image;
     }
-  header_magick_size = ReadBlob(image, Min(sizeof(header_magick),PS_Size), header_magick);
+  header_magick_size = ReadBlob((*image), Min(sizeof(header_magick),PS_Size), header_magick);
   format[0]='\0';
   /*
     MagickExport MagickPassFail
@@ -868,8 +868,8 @@
     {
       (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                             "Failed to identify embedded file type!");
-      ThrowException(exception,CorruptImageError,UnableToReadImageHeader,image->filename);
-      return image;
+      ThrowException(exception,CorruptImageError,UnableToReadImageHeader,(*image)->filename);
+      return *image;
     }
 
   /*
@@ -879,57 +879,57 @@
   {
     (void) LogMagickEvent(CoderEvent, GetMagickModule(),
                         "Format \"%s\" cannot be embedded inside WPG.", format);
-    ThrowException(exception,CorruptImageError,UnableToReadImageHeader,image->filename);
-    return image;
+    ThrowException(exception,CorruptImageError,UnableToReadImageHeader,(*image)->filename);
+    return *image;
   }
 
   /*
     Restore seek offset after reading header
   */
-  if (SeekBlob(image,PS_Offset,SEEK_SET) != PS_Offset)
+  if (SeekBlob((*image),PS_Offset,SEEK_SET) != PS_Offset)
     {
-      if (image->logging)
+      if ((*image)->logging)
         (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                               "ExtractPostscript(): Failed to seek to PS_Offset=%"MAGICK_OFF_F"d",
                               (magick_off_t) PS_Offset);
-      ThrowException(exception,CorruptImageError,UnexpectedEndOfFile,image->filename);
-      return image;
+      ThrowException(exception,CorruptImageError,UnexpectedEndOfFile,(*image)->filename);
+      return *image;
     }
   /*
     Allocate buffer if zero-copy read is not possible.
   */
-  if (GetBlobStreamData(image) == (unsigned char *) NULL)
+  if (GetBlobStreamData((*image)) == (unsigned char *) NULL)
     {
       ps_data_alloc=MagickAllocateResourceLimitedMemory(unsigned char *, PS_Size);
       if (ps_data_alloc == (unsigned char *) NULL)
         {
-          if (image->logging)
+          if ((*image)->logging)
             (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                                   "ExtractPostscript(): Failed to allocate "
                                   "%"MAGICK_SIZE_T_F"u bytes of memory",
                                   (MAGICK_SIZE_T) PS_Size);
-          ThrowException(exception,ResourceLimitError,MemoryAllocationFailed,image->filename);
-          return image;
+          ThrowException(exception,ResourceLimitError,MemoryAllocationFailed,(*image)->filename);
+          return *image;
         }
     }
   /*
     Use a zero-copy read when possible to access data
   */
   ps_data=ps_data_alloc;
-  if (ReadBlobZC(image,PS_Size,&ps_data) != PS_Size)
+  if (ReadBlobZC((*image),PS_Size,&ps_data) != PS_Size)
     {
       MagickFreeResourceLimitedMemory(ps_data_alloc);
-      if (image->logging)
+      if ((*image)->logging)
         (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                               "ExtractPostscript(): Failed to read %"MAGICK_SIZE_T_F"u bytes of data at"
                               " offset=%"MAGICK_OFF_F"d",
                               (MAGICK_SIZE_T) PS_Size, (magick_off_t) PS_Offset);
-      ThrowException(exception,CorruptImageError,UnexpectedEndOfFile,image->filename);