From: Cristy Date: Wed, 26 Apr 2017 21:16:56 +0000 (-0400) Subject: https://github.com/ImageMagick/ImageMagick/issues/449 X-Git-Tag: 7.0.5-6~48 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=dbc1e15ebc8e9bc4ff4a17cf603ba1ccecf477e3;p=imagemagick https://github.com/ImageMagick/ImageMagick/issues/449 --- diff --git a/coders/sun.c b/coders/sun.c index c3d87dc45..c10562f67 100644 --- a/coders/sun.c +++ b/coders/sun.c @@ -363,19 +363,28 @@ static Image *ReadSUNImage(const ImageInfo *image_info,ExceptionInfo *exception) ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); count=ReadBlob(image,image->colors,sun_colormap); if (count != (ssize_t) image->colors) - ThrowReaderException(CorruptImageError,"UnexpectedEndOfFile"); + { + sun_colormap=(unsigned char *) RelinquishMagickMemory(sun_colormap); + ThrowReaderException(CorruptImageError,"UnexpectedEndOfFile"); + } for (i=0; i < (ssize_t) image->colors; i++) image->colormap[i].red=(MagickRealType) ScaleCharToQuantum( sun_colormap[i]); count=ReadBlob(image,image->colors,sun_colormap); if (count != (ssize_t) image->colors) - ThrowReaderException(CorruptImageError,"UnexpectedEndOfFile"); + { + sun_colormap=(unsigned char *) RelinquishMagickMemory(sun_colormap); + ThrowReaderException(CorruptImageError,"UnexpectedEndOfFile"); + } for (i=0; i < (ssize_t) image->colors; i++) image->colormap[i].green=(MagickRealType) ScaleCharToQuantum( sun_colormap[i]); count=ReadBlob(image,image->colors,sun_colormap); if (count != (ssize_t) image->colors) - ThrowReaderException(CorruptImageError,"UnexpectedEndOfFile"); + { + sun_colormap=(unsigned char *) RelinquishMagickMemory(sun_colormap); + ThrowReaderException(CorruptImageError,"UnexpectedEndOfFile"); + } for (i=0; i < (ssize_t) image->colors; i++) image->colormap[i].blue=(MagickRealType) ScaleCharToQuantum( sun_colormap[i]); @@ -395,9 +404,9 @@ static Image *ReadSUNImage(const ImageInfo *image_info,ExceptionInfo *exception) if (sun_colormap == (unsigned char *) NULL) ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); count=ReadBlob(image,sun_info.maplength,sun_colormap); + sun_colormap=(unsigned char *) RelinquishMagickMemory(sun_colormap); if (count != (ssize_t) sun_info.maplength) ThrowReaderException(CorruptImageError,"UnexpectedEndOfFile"); - sun_colormap=(unsigned char *) RelinquishMagickMemory(sun_colormap); break; } default: