Skip to content

Commit

Permalink
Fixed memory leak reported in #459.
Browse files Browse the repository at this point in the history
  • Loading branch information
dlemstra committed May 2, 2017
1 parent ba8fa4c commit 3a7e63b
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions coders/palm.c
Expand Up @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit 3a7e63b

Please sign in to comment.