From f308152b28249d599fa01dd41b1518c4ddfc5e60 Mon Sep 17 00:00:00 2001 From: dirk <dirk@git.imagemagick.org> Date: Sun, 21 Jun 2015 09:31:18 +0000 Subject: [PATCH] Removed unnecessary calls to DiscardBlobBytes. --- coders/psd.c | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/coders/psd.c b/coders/psd.c index fe7c58e85..3c133ca33 100644 --- a/coders/psd.c +++ b/coders/psd.c @@ -1256,26 +1256,14 @@ ModuleExport MagickStatusType ReadPSDLayers(Image *image, count=ReadBlob(image,4,(unsigned char *) type); status=MagickFalse; if ((count == 0) || (LocaleNCompare(type,"8BIM",4) != 0)) - { - if (size >= (quantum+8)) - status=DiscardBlobBytes(image,(MagickSizeType) (size-quantum-8)); - if (status == MagickFalse) - ThrowBinaryException(CorruptImageError,"UnexpectedEndOfFile", - image->filename); - } + return(MagickTrue); else { count=ReadBlob(image,4,(unsigned char *) type); if ((count != 0) && (LocaleNCompare(type,"Lr16",4) == 0)) size=GetPSDSize(psd_info,image); else - { - if (size >= (quantum+12)) - status=DiscardBlobBytes(image,(MagickSizeType) (size-quantum-12)); - if (status == MagickFalse) - ThrowBinaryException(CorruptImageError,"UnexpectedEndOfFile", - image->filename); - } + return(MagickTrue); } } status=MagickTrue; @@ -1297,6 +1285,9 @@ ModuleExport MagickStatusType ReadPSDLayers(Image *image, image->alpha_trait=BlendPixelTrait; } + /* + We only need to know if the image has an alpha channel + */ if (skip_layers != MagickFalse) return(MagickTrue); @@ -1694,7 +1685,7 @@ static Image *ReadPSDImage(const ImageInfo *image_info,ExceptionInfo *exception) if ((count == 0) || (LocaleNCompare(psd_info.signature,"8BPS",4) != 0) || ((psd_info.version != 1) && (psd_info.version != 2))) ThrowReaderException(CorruptImageError,"ImproperImageHeader"); - count=ReadBlob(image,6,psd_info.reserved); + (void) ReadBlob(image,6,psd_info.reserved); psd_info.channels=ReadBlobMSBShort(image); if (psd_info.channels > MaxPSDChannels) ThrowReaderException(CorruptImageError,"MaximumChannelsExceeded"); @@ -1770,7 +1761,7 @@ static Image *ReadPSDImage(const ImageInfo *image_info,ExceptionInfo *exception) sizeof(*data)); if (data == (unsigned char *) NULL) ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); - count=ReadBlob(image,(size_t) length,data); + (void) ReadBlob(image,(size_t) length,data); data=(unsigned char *) RelinquishMagickMemory(data); } else @@ -2844,8 +2835,9 @@ static MagickBooleanType WritePSDImage(const ImageInfo *image_info,Image *image, /* Write composite image. */ - status=WriteImageChannels(&psd_info,image_info,image,image,MagickFalse, - exception); + if (status != MagickFalse) + status=WriteImageChannels(&psd_info,image_info,image,image,MagickFalse, + exception); (void) CloseBlob(image); return(status); } -- 2.40.0