From bf6abbe1b8479901cb9fba4d8ad74772d3042fc8 Mon Sep 17 00:00:00 2001 From: cristy Date: Thu, 1 Sep 2011 13:20:47 +0000 Subject: [PATCH] --- coders/gif.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/coders/gif.c b/coders/gif.c index 27e0f60ad..9d8f722dc 100644 --- a/coders/gif.c +++ b/coders/gif.c @@ -1153,6 +1153,9 @@ static Image *ReadGIFImage(const ImageInfo *image_info,ExceptionInfo *exception) " Reading GIF application extension"); info=(unsigned char *) AcquireQuantumMemory(255UL, sizeof(*info)); + if (info == (unsigned char *) NULL) + ThrowReaderException(ResourceLimitError, + "MemoryAllocationFailed"); reserved_length=255; for (info_length=0; ; ) { @@ -1165,12 +1168,16 @@ static Image *ReadGIFImage(const ImageInfo *image_info,ExceptionInfo *exception) reserved_length+=4096; info=(unsigned char *) ResizeQuantumMemory(info, (size_t) reserved_length,sizeof(*info)); + if (info == (unsigned char *) NULL) + ThrowReaderException(ResourceLimitError, + "MemoryAllocationFailed"); } } - info=(unsigned char *) ResizeQuantumMemory(info,(size_t) - (info_length+1),sizeof(*info)); - profile=AcquireStringInfo((size_t) info_length); - SetStringInfoDatum(profile,(const unsigned char *) info); + profile=BlobToStringInfo(info,(size_t) info_length); + if (profile == (StringInfo *) NULL) + ThrowReaderException(ResourceLimitError, + "MemoryAllocationFailed"); + info=(unsigned char *) RelinquishMagickMemory(info); if (i8bim == MagickTrue) (void) CopyMagickString(name,"8bim",sizeof(name)); else if (icc == MagickTrue) @@ -1181,7 +1188,6 @@ static Image *ReadGIFImage(const ImageInfo *image_info,ExceptionInfo *exception) (void) FormatLocaleString(name,sizeof(name),"gif:%.11s", header); (void) SetImageProfile(image,name,profile); - info=(unsigned char *) RelinquishMagickMemory(info); profile=DestroyStringInfo(profile); (void) LogMagickEvent(CoderEvent,GetMagickModule(), " profile name=%s",name); -- 2.40.0