]> granicus.if.org Git - imagemagick/commitdiff
(no commit message)
authorcristy <urban-warrior@git.imagemagick.org>
Sun, 27 Feb 2011 16:51:16 +0000 (16:51 +0000)
committercristy <urban-warrior@git.imagemagick.org>
Sun, 27 Feb 2011 16:51:16 +0000 (16:51 +0000)
coders/psd.c

index f515295c4ca43ec5dc0f8d6ede457eed4e8fae04..7163c75aa754859be3a37091b5323c1a73d639c6 100644 (file)
@@ -940,31 +940,13 @@ static Image *ReadPSDImage(const ImageInfo *image_info,ExceptionInfo *exception)
           size_t
             quantum;
 
-          unsigned char
-            *blocks;
-
           /*
             Skip layers & masks.
           */
           quantum=psd_info.version == 1 ? 4UL : 8UL;
-          size=ReadBlobMSBLong(image);
-          length-=(quantum+4);
-          if (image->debug != MagickFalse)
-            (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-              "  reading image resource blocks - %.20g bytes",(double) length);
-          blocks=(unsigned char *) AcquireQuantumMemory((size_t) length,
-            sizeof(*blocks));
-          if (blocks == (unsigned char *) NULL)
-            ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
-          count=ReadBlob(image,(size_t) length,blocks);
-          if ((count != (ssize_t) length) ||
-              (LocaleNCompare((char *) blocks,"8BIM",4) != 0))
-            {
-              blocks=(unsigned char *) RelinquishMagickMemory(blocks);
-              ThrowReaderException(CorruptImageError,"ImproperImageHeader");
-            }
-          (void) ParseImageResourceBlocks(image,blocks,(size_t) length);
-          blocks=(unsigned char *) RelinquishMagickMemory(blocks);
+          if (DiscardBlobBytes(image,length-quantum) == MagickFalse)
+            ThrowFileException(exception,CorruptImageError,
+              "UnexpectedEndOfFile",image->filename);
         }
       else
         {