From ba214881e6af74cdb5edb2ae9f8ca8eedf9fa60e Mon Sep 17 00:00:00 2001 From: Cristy Date: Sun, 10 Sep 2017 11:03:51 -0400 Subject: [PATCH] Throw exception if cache nexus width or height are zero --- MagickCore/cache.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/MagickCore/cache.c b/MagickCore/cache.c index dc7187bf0..8b5a91fb4 100644 --- a/MagickCore/cache.c +++ b/MagickCore/cache.c @@ -4802,7 +4802,13 @@ static Quantum *SetPixelCacheNexusPixels(const CacheInfo *cache_info, assert(cache_info->signature == MagickCoreSignature); if (cache_info->type == UndefinedCache) return((Quantum *) NULL); + if ((region->width == 0) || (region->height == 0)) + return((Quantum *) NULL); nexus_info->region=(*region); + number_pixels=(MagickSizeType) nexus_info->region.width* + nexus_info->region.height; + if (number_pixels == 0) + return((Quantum *) NULL); if ((cache_info->type == MemoryCache) || (cache_info->type == MapCache)) { ssize_t @@ -4840,8 +4846,6 @@ static Quantum *SetPixelCacheNexusPixels(const CacheInfo *cache_info, /* Pixels are stored in a staging region until they are synced to the cache. */ - number_pixels=(MagickSizeType) nexus_info->region.width* - nexus_info->region.height; length=number_pixels*cache_info->number_channels*sizeof(Quantum); if (cache_info->metacontent_extent != 0) length+=number_pixels*cache_info->metacontent_extent; -- 2.50.1