Skip to content

Commit

Permalink
https://github.com/ImageMagick/ImageMagick/issues/573
Browse files Browse the repository at this point in the history
  • Loading branch information
Cristy committed Jul 17, 2017
1 parent d555940 commit 1dc0ac5
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions coders/map.c
Original file line number Diff line number Diff line change
Expand Up @@ -391,12 +391,17 @@ static MagickBooleanType WriteMAPImage(const ImageInfo *image_info,Image *image,
sizeof(*colormap));
if ((pixels == (unsigned char *) NULL) ||
(colormap == (unsigned char *) NULL))
ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed");
{
if (colormap != (unsigned char *) NULL)
colormap=(unsigned char *) RelinquishMagickMemory(colormap);
if (pixels != (unsigned char *) NULL)
pixels=(unsigned char *) RelinquishMagickMemory(pixels);
ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed");
}
/*
Write colormap to file.
*/
q=colormap;
q=colormap;
if (image->colors <= 256)
for (i=0; i < (ssize_t) image->colors; i++)
{
Expand All @@ -410,9 +415,11 @@ static MagickBooleanType WriteMAPImage(const ImageInfo *image_info,Image *image,
*q++=(unsigned char) (ScaleQuantumToShort(image->colormap[i].red) >> 8);
*q++=(unsigned char) (ScaleQuantumToShort(image->colormap[i].red) & 0xff);
*q++=(unsigned char) (ScaleQuantumToShort(image->colormap[i].green) >> 8);
*q++=(unsigned char) (ScaleQuantumToShort(image->colormap[i].green) & 0xff);;
*q++=(unsigned char) (ScaleQuantumToShort(image->colormap[i].green) &
0xff);
*q++=(unsigned char) (ScaleQuantumToShort(image->colormap[i].blue) >> 8);
*q++=(unsigned char) (ScaleQuantumToShort(image->colormap[i].blue) & 0xff);
*q++=(unsigned char) (ScaleQuantumToShort(image->colormap[i].blue) &
0xff);
}
(void) WriteBlob(image,packet_size*image->colors,colormap);
colormap=(unsigned char *) RelinquishMagickMemory(colormap);
Expand Down

0 comments on commit 1dc0ac5

Please sign in to comment.