From e403976ace25b0eb5c7359ab7dfb66f11d81ebe4 Mon Sep 17 00:00:00 2001 From: Cristy Date: Sat, 22 Dec 2018 20:12:17 -0500 Subject: [PATCH] https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=12160 --- coders/cube.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/coders/cube.c b/coders/cube.c index d0a8fef4e..aa119bc48 100644 --- a/coders/cube.c +++ b/coders/cube.c @@ -176,11 +176,17 @@ static Image *ReadCUBEImage(const ImageInfo *image_info, GetNextToken(q,&q,MagickPathExtent,value); cube_level=(size_t) StringToLong(value); if ((cube_level < 2) || (cube_level > 65536)) - ThrowReaderException(CorruptImageError,"ImproperImageHeader"); + { + buffer=DestroyString(buffer); + ThrowReaderException(CorruptImageError,"ImproperImageHeader"); + } cube_info=AcquireVirtualMemory(cube_level*cube_level,cube_level* sizeof(*cube)); if (cube_info == (MemoryInfo *) NULL) - ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); + { + buffer=DestroyString(buffer); + ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); + } cube=(CubePixel *) GetVirtualMemoryBlob(cube_info); (void) memset(cube,0,cube_level*cube_level*cube_level*sizeof(*cube)); } -- 2.40.0