From 061de02095a56d438409c63f723f340b2d9d36c7 Mon Sep 17 00:00:00 2001 From: Cristy Date: Tue, 4 Jul 2017 13:57:51 -0400 Subject: [PATCH] https://github.com/ImageMagick/ImageMagick/issues/536 --- MagickCore/memory.c | 4 +++- coders/pcx.c | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/MagickCore/memory.c b/MagickCore/memory.c index aaa17a2c8..dbf644fff 100644 --- a/MagickCore/memory.c +++ b/MagickCore/memory.c @@ -667,11 +667,13 @@ MagickExport MemoryInfo *AcquireVirtualMemory(const size_t count, } RelinquishMagickResource(MapResource,extent); } - if (memory_info->blob == NULL) + if ((memory_info->blob == NULL) && + (AcquireMagickResource(MemoryResource,extent) != MagickFalse)) { memory_info->blob=AcquireMagickMemory(extent); if (memory_info->blob != NULL) memory_info->type=UnalignedVirtualMemory; + RelinquishMagickResource(MemoryResource,extent); } if (memory_info->blob == NULL) memory_info=RelinquishVirtualMemory(memory_info); diff --git a/coders/pcx.c b/coders/pcx.c index a441a40af..0c0dda15a 100644 --- a/coders/pcx.c +++ b/coders/pcx.c @@ -358,6 +358,8 @@ static Image *ReadPCXImage(const ImageInfo *image_info,ExceptionInfo *exception) pcx_info.planes=(unsigned char) ReadBlobByte(image); if (pcx_info.planes == 0) ThrowPCXException(CorruptImageError,"ImproperImageHeader"); + if (pcx_info.planes > 6) + ThrowPCXException(CorruptImageError,"ImproperImageHeader"); if ((pcx_info.bits_per_pixel*pcx_info.planes) >= 64) ThrowPCXException(CorruptImageError,"ImproperImageHeader"); one=1; -- 2.40.0