From: Cristy Date: Sun, 10 Mar 2019 13:12:05 +0000 (-0400) Subject: ... X-Git-Tag: 7.0.8-33~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c805e32059a06db68613dacc0e536365308ecb8e;p=imagemagick ... --- diff --git a/MagickCore/cache-private.h b/MagickCore/cache-private.h index c37468b3e..9c8215160 100644 --- a/MagickCore/cache-private.h +++ b/MagickCore/cache-private.h @@ -226,6 +226,10 @@ typedef struct _CacheInfo MagickBooleanType composite_mask; + + MagickSizeType + width_limit, + height_limit; } CacheInfo; extern MagickPrivate Cache diff --git a/MagickCore/cache.c b/MagickCore/cache.c index 33ea96579..04bd96fd4 100644 --- a/MagickCore/cache.c +++ b/MagickCore/cache.c @@ -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);