From: Cristy Date: Thu, 16 Feb 2017 13:41:33 +0000 (-0500) Subject: ... X-Git-Tag: 7.0.4-10~9 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5c5d1e098a027243b070215c554fe0b54e074659;p=imagemagick ... --- diff --git a/MagickCore/cache.c b/MagickCore/cache.c index c7f112449..92c06976d 100644 --- a/MagickCore/cache.c +++ b/MagickCore/cache.c @@ -156,6 +156,9 @@ static volatile MagickBooleanType static SemaphoreInfo *cache_semaphore = (SemaphoreInfo *) NULL; +static ssize_t + anonymous_pixel_cache = (-1); + static time_t cache_epoch = 0; @@ -3430,6 +3433,20 @@ static MagickBooleanType OpenPixelCache(Image *image,const MapMode mode, assert(image->cache != (Cache) NULL); if (image->debug != MagickFalse) (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); + if (anonymous_pixel_cache < 0) + { + char + *value; + + /* + Does the security policy require anonymous mapping for pixel cache? + */ + anonymous_pixel_cache=0; + value=GetPolicyValue("pixel-cache"); + if (LocaleCompare(value,"anonymous") == 0) + anonymous_pixel_cache=1; + value=DestroyString(value); + } if ((image->columns == 0) || (image->rows == 0)) ThrowBinaryException(CacheError,"NoPixelsDefinedInCache",image->filename); cache_info=(CacheInfo *) image->cache; @@ -3478,23 +3495,6 @@ static MagickBooleanType OpenPixelCache(Image *image,const MapMode mode, cache_info->metacontent_extent); if ((status != MagickFalse) && (length == (MagickSizeType) ((size_t) length))) { - static ssize_t - anonymous_pixel_cache = (-1); - - if (anonymous_pixel_cache < 0) - { - char - *value; - - /* - Does the security policy require anonymous mapping for pixel cache? - */ - anonymous_pixel_cache=0; - value=GetPolicyValue("pixel-cache"); - if (LocaleCompare(value,"anonymous") == 0) - anonymous_pixel_cache=1; - value=DestroyString(value); - } status=AcquireMagickResource(MemoryResource,cache_info->length); if (((cache_info->type == UndefinedCache) && (status != MagickFalse)) || (cache_info->type == MemoryCache)) @@ -4694,11 +4694,12 @@ static inline MagickBooleanType AcquireCacheNexusPixels( { if (nexus_info->length != (MagickSizeType) ((size_t) nexus_info->length)) return(MagickFalse); - nexus_info->mapped=MagickFalse; - nexus_info->cache=(Quantum *) MagickAssumeAligned(AcquireAlignedMemory(1, - (size_t) nexus_info->length)); - if (nexus_info->cache != (Quantum *) NULL) - (void) ResetMagickMemory(nexus_info->cache,0,nexus_info->length); + if (anonymous_pixel_cache == 0) + { + nexus_info->mapped=MagickFalse; + nexus_info->cache=(Quantum *) MagickAssumeAligned(AcquireAlignedMemory(1, + (size_t) nexus_info->length)); + } else { nexus_info->mapped=MagickTrue;