]> granicus.if.org Git - imagemagick/commitdiff
Throw exception if cache nexus width or height are zero
authorCristy <urban-warrior@imagemagick.org>
Sun, 10 Sep 2017 15:03:51 +0000 (11:03 -0400)
committerCristy <urban-warrior@imagemagick.org>
Sun, 10 Sep 2017 15:03:51 +0000 (11:03 -0400)
MagickCore/cache.c

index dc7187bf0250d5d776e947e9ea0537157788d53f..8b5a91fb4c81f8aa981492cb0e7cd9a940061ebe 100644 (file)
@@ -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;