From: cristy Date: Fri, 16 Apr 2010 18:12:35 +0000 (+0000) Subject: (no commit message) X-Git-Tag: 7.0.1-0~9637 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e195f269ded3cc73598398d43649ad5adca19e44;p=imagemagick --- diff --git a/coders/psd.c b/coders/psd.c index 3b17aff47..22edbab93 100644 --- a/coders/psd.c +++ b/coders/psd.c @@ -562,12 +562,19 @@ static MagickBooleanType ReadPSDLayer(Image *image, compact_pixels=(unsigned char *) NULL; if (image->compression == RLECompression) { - compact_pixels=(unsigned char *) AcquireQuantumMemory(image->columns+256, - packet_size*sizeof(*pixels)); + size_t + length; + + length=0; + for (y=0; y < (long) image->rows; y++) + if ((MagickOffsetType) length < offsets[y]) + length=offsets[y]; + compact_pixels=(unsigned char *) AcquireQuantumMemory(length, + sizeof(*pixels)); if (compact_pixels == (unsigned char *) NULL) ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed", image->filename); - (void) ResetMagickMemory(compact_pixels,0,image->columns*packet_size* + (void) ResetMagickMemory(compact_pixels,0,length* sizeof(*compact_pixels)); } for (y=0; y < (long) image->rows; y++) @@ -2017,7 +2024,7 @@ static MagickBooleanType WritePSDImage(const ImageInfo *image_info,Image *image) (void) WriteBlobMSBLong(image,GetStringInfoLength(icc_profile)); (void) WriteBlob(image,GetStringInfoLength(icc_profile), GetStringInfoDatum(icc_profile)); - if (GetStringInfoLength(icc_profile) != + if ((MagickOffsetType) GetStringInfoLength(icc_profile) != PSDQuantum(GetStringInfoLength(icc_profile))) (void) WriteBlobByte(image,0); }