diff options
author | Cristy <urban-warrior@imagemagick.org> | 2017-07-17 13:32:16 -0400 |
---|---|---|
committer | Cristy <urban-warrior@imagemagick.org> | 2017-07-17 13:32:16 -0400 |
commit | 1dc0ac5016f1c4d50b100a086526d6a2453a5444 (patch) | |
tree | a2c03e48049d4626a830d6ed84f0d202d94a4746 /coders/map.c | |
parent | d5559407ce29f4371e5df9c1cbde65455fe5854c (diff) | |
download | ImageMagick-1dc0ac5016f1c4d50b100a086526d6a2453a5444.tar.gz |
https://github.com/ImageMagick/ImageMagick/issues/573
Diffstat (limited to 'coders/map.c')
-rw-r--r-- | coders/map.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/coders/map.c b/coders/map.c index 5cee51560..5383b6d9f 100644 --- a/coders/map.c +++ b/coders/map.c @@ -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++) { @@ -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); |