]> granicus.if.org Git - imagemagick/commitdiff
...
authorCristy <urban-warrior@imagemagick.org>
Thu, 16 Feb 2017 13:41:33 +0000 (08:41 -0500)
committerCristy <urban-warrior@imagemagick.org>
Thu, 16 Feb 2017 13:41:33 +0000 (08:41 -0500)
MagickCore/cache.c

index c7f112449ebd885f5078fdb9621906cc7a108ffe..92c06976d7c7989a81cf9237bfc2e47c65efba6b 100644 (file)
@@ -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;
 \f
@@ -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;