diff options
author | root <356986351@qq.com> | 2017-09-15 16:31:45 +0000 |
---|---|---|
committer | Dirk Lemstra <dlemstra@users.noreply.github.com> | 2017-09-16 15:29:09 +0200 |
commit | c901886efecdd8acc8435dfac70cfbec52bd3586 (patch) | |
tree | 8b49b18cf9c1fd28243aeffb810ad5ab35653894 /coders/map.c | |
parent | db9c47230cc5a1e866942fc9d73d8e81b93ffc3a (diff) | |
download | ImageMagick-c901886efecdd8acc8435dfac70cfbec52bd3586.tar.gz |
fix memory leak in map
Diffstat (limited to 'coders/map.c')
-rw-r--r-- | coders/map.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/coders/map.c b/coders/map.c index 374ccfb14..558bb90ad 100644 --- a/coders/map.c +++ b/coders/map.c @@ -169,13 +169,21 @@ static Image *ReadMAPImage(const ImageInfo *image_info,ExceptionInfo *exception) sizeof(*colormap)); if ((pixels == (unsigned char *) NULL) || (colormap == (unsigned char *) NULL)) - ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); + { + pixels=(unsigned char *) RelinquishMagickMemory(pixels); + colormap=(unsigned char *) RelinquishMagickMemory(colormap); + ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); + } /* Read image colormap. */ count=ReadBlob(image,packet_size*image->colors,colormap); if (count != (ssize_t) (packet_size*image->colors)) - ThrowReaderException(CorruptImageError,"InsufficientImageDataInFile"); + { + pixels=(unsigned char *) RelinquishMagickMemory(pixels); + colormap=(unsigned char *) RelinquishMagickMemory(colormap); + ThrowReaderException(CorruptImageError,"InsufficientImageDataInFile"); + } p=colormap; if (image->depth <= 8) for (i=0; i < (ssize_t) image->colors; i++) @@ -201,11 +209,15 @@ static Image *ReadMAPImage(const ImageInfo *image_info,ExceptionInfo *exception) if (image_info->ping != MagickFalse) { (void) CloseBlob(image); + pixels=(unsigned char *) RelinquishMagickMemory(pixels); return(GetFirstImageInList(image)); } status=SetImageExtent(image,image->columns,image->rows,exception); if (status == MagickFalse) - return(DestroyImageList(image)); + { + pixels=(unsigned char *) RelinquishMagickMemory(pixels); + return(DestroyImageList(image)); + } /* Read image pixels. */ |