From: Dirk Lemstra Date: Tue, 2 May 2017 06:42:22 +0000 (+0200) Subject: Fixed memory leak reported in #459. X-Git-Tag: 7.0.5-6~29 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3a7e63bc27e3e84cec4617125fa7641d77b90e65;p=imagemagick Fixed memory leak reported in #459. --- diff --git a/coders/palm.c b/coders/palm.c index 2905f4303..66fde84d3 100644 --- a/coders/palm.c +++ b/coders/palm.c @@ -477,7 +477,12 @@ static Image *ReadPALMImage(const ImageInfo *image_info, if (bits_per_pixel == 16) { if (image->columns > (2*bytes_per_row)) - ThrowReaderException(CorruptImageError,"CorruptImage"); + { + one_row=(unsigned char *) RelinquishMagickMemory(one_row); + if (compressionType == PALM_COMPRESSION_SCANLINE) + lastrow=(unsigned char *) RelinquishMagickMemory(lastrow); + ThrowReaderException(CorruptImageError,"CorruptImage"); + } for (x=0; x < (ssize_t) image->columns; x++) { color16=(*ptr++ << 8); @@ -498,7 +503,12 @@ static Image *ReadPALMImage(const ImageInfo *image_info, for (x=0; x < (ssize_t) image->columns; x++) { if ((size_t) (ptr-one_row) >= bytes_per_row) - ThrowReaderException(CorruptImageError,"CorruptImage"); + { + one_row=(unsigned char *) RelinquishMagickMemory(one_row); + if (compressionType == PALM_COMPRESSION_SCANLINE) + lastrow=(unsigned char *) RelinquishMagickMemory(lastrow); + ThrowReaderException(CorruptImageError,"CorruptImage"); + } index=(Quantum) (mask-(((*ptr) & (mask << bit)) >> bit)); SetPixelIndex(image,index,q); SetPixelViaPixelInfo(image,image->colormap+(ssize_t) index,q);