From: root <356986351@qq.com> Date: Fri, 15 Sep 2017 16:31:45 +0000 (+0000) Subject: fix memory leak in map X-Git-Tag: 7.0.7-3~19 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c901886efecdd8acc8435dfac70cfbec52bd3586;p=imagemagick fix memory leak in map --- 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. */