]> granicus.if.org Git - imagemagick/commitdiff
...
authorCristy <mikayla-grace@urban-warrior.org>
Sun, 10 Mar 2019 13:12:05 +0000 (09:12 -0400)
committerCristy <mikayla-grace@urban-warrior.org>
Sun, 10 Mar 2019 13:12:05 +0000 (09:12 -0400)
MagickCore/cache-private.h
MagickCore/cache.c

index c37468b3e267b12743256541c193634bdf4ee180..9c821516055809f67a1b9d8acb489780092e6987 100644 (file)
@@ -226,6 +226,10 @@ typedef struct _CacheInfo
 
   MagickBooleanType
     composite_mask;
+
+  MagickSizeType
+    width_limit,
+    height_limit;
 } CacheInfo;
 
 extern MagickPrivate Cache
index 33ea96579633d1544fee78c52377c17faa29f787..04bd96fd4f1e7a8376fe643e547aedac5cfc10f4 100644 (file)
@@ -222,6 +222,8 @@ MagickPrivate Cache AcquirePixelCache(const size_t number_threads)
       cache_info->synchronize=IsStringTrue(value);
       value=DestroyString(value);
     }
+  cache_info->width_limit=GetMagickResourceLimit(WidthResource);
+  cache_info->height_limit=GetMagickResourceLimit(HeightResource);
   cache_info->semaphore=AcquireSemaphoreInfo();
   cache_info->reference_count=1;
   cache_info->file_semaphore=AcquireSemaphoreInfo();
@@ -3694,8 +3696,8 @@ static MagickBooleanType OpenPixelCache(Image *image,const MapMode mode,
     ThrowBinaryException(CacheError,"NoPixelsDefinedInCache",image->filename);
   cache_info=(CacheInfo *) image->cache;
   assert(cache_info->signature == MagickCoreSignature);
-  if ((AcquireMagickResource(WidthResource,image->columns) == MagickFalse) ||
-      (AcquireMagickResource(HeightResource,image->rows) == MagickFalse))
+  if (((MagickSizeType) image->columns > cache_info->width_limit) ||
+      ((MagickSizeType) image->rows > cache_info->height_limit))
     ThrowBinaryException(ImageError,"WidthOrHeightExceedsLimit",
       image->filename);
   length=GetImageListLength(image);
@@ -5074,10 +5076,8 @@ static Quantum *SetPixelCacheNexusPixels(const CacheInfo *cache_info,
   /*
     Pixels are stored in a staging region until they are synced to the cache.
   */
-  if (((region->x != (ssize_t) nexus_info->region.width) ||
-       (region->y != (ssize_t) nexus_info->region.height)) &&
-      ((AcquireMagickResource(WidthResource,region->width) == MagickFalse) ||
-       (AcquireMagickResource(HeightResource,region->height) == MagickFalse)))
+  if (((MagickSizeType) region->width > cache_info->width_limit) ||
+      ((MagickSizeType) region->height > cache_info->height_limit))
     {
       (void) ThrowMagickException(exception,GetMagickModule(),ImageError,
         "WidthOrHeightExceedsLimit","`%s'",cache_info->filename);