]> granicus.if.org Git - imagemagick/commitdiff
Proper resource bookkeeping
authorCristy <urban-warrior@imagemagick.org>
Fri, 24 Nov 2017 16:26:57 +0000 (11:26 -0500)
committerCristy <urban-warrior@imagemagick.org>
Fri, 24 Nov 2017 16:26:57 +0000 (11:26 -0500)
MagickCore/cache.c
MagickCore/resource.c
coders/jpeg.c

index dae3aa8d77510487ab69ae240f2ffde95223318d..926fe0f73e38a7caf96b294d6c90d387c9374f01 100644 (file)
@@ -3578,7 +3578,6 @@ static MagickBooleanType OpenPixelCache(Image *image,const MapMode mode,
               return(status == 0 ? MagickFalse : MagickTrue);
             }
         }
-      RelinquishMagickResource(MemoryResource,cache_info->length);
     }
   /*
     Create pixel cache on disk.
@@ -3640,7 +3639,7 @@ static MagickBooleanType OpenPixelCache(Image *image,const MapMode mode,
               return(status == 0 ? MagickFalse : MagickTrue);
             }
         }
-      RelinquishMagickResource(DiskResource,cache_info->length);
+      cache_info->type=UndefinedCache;
       (void) ThrowMagickException(exception,GetMagickModule(),CacheError,
         "CacheResourcesExhausted","`%s'",image->filename);
       return(MagickFalse);
@@ -3726,7 +3725,6 @@ static MagickBooleanType OpenPixelCache(Image *image,const MapMode mode,
               return(status == 0 ? MagickFalse : MagickTrue);
             }
         }
-      RelinquishMagickResource(MapResource,cache_info->length);
     }
   status=MagickTrue;
   if ((source_info.storage_class != UndefinedClass) && (mode != ReadMode))
index 28980000e4d426943cebf5068f72cc584a0f4358..31a0bde991e2357db444d04d06d38e34f65c2867 100644 (file)
@@ -958,8 +958,9 @@ MagickExport void RelinquishMagickResource(const ResourceType type,
         {
           (void) FormatMagickSize(size,MagickFalse,(const char *) NULL,
             MagickFormatExtent,resource_request);
-          (void) FormatMagickSize((MagickSizeType) resource_info.area,MagickFalse,
-            (const char *) NULL,MagickFormatExtent,resource_current);
+          (void) FormatMagickSize((MagickSizeType) resource_info.area,
+            MagickFalse,(const char *) NULL,MagickFormatExtent,
+            resource_current);
           (void) FormatMagickSize(resource_info.area_limit,MagickFalse,
             (const char *) NULL,MagickFormatExtent,resource_limit);
         }
@@ -1086,8 +1087,8 @@ MagickExport void RelinquishMagickResource(const ResourceType type,
         {
           (void) FormatMagickSize(size,MagickFalse,"P",MagickFormatExtent,
             resource_request);
-          (void) FormatMagickSize((MagickSizeType) resource_info.width,MagickFalse,
-            "P",MagickFormatExtent,resource_current);
+          (void) FormatMagickSize((MagickSizeType) resource_info.width,
+            MagickFalse,"P",MagickFormatExtent,resource_current);
           (void) FormatMagickSize(resource_info.width_limit,MagickFalse,"P",
             MagickFormatExtent,resource_limit);
         }
index a24be919943c988e63af81a21457e62309f4ca44..dd3450d09088180cb032541aec9b0851f4330d84 100644 (file)
@@ -1263,8 +1263,7 @@ static Image *ReadJPEGImage(const ImageInfo *image_info,
     }
   option=GetImageOption(image_info,"jpeg:colors");
   if (option != (const char *) NULL)
-    if (AcquireImageColormap(image,StringToUnsignedLong(option),exception)
-         == MagickFalse)
+    if (AcquireImageColormap(image,StringToUnsignedLong(option),exception) == MagickFalse)
       ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
   if ((jpeg_info.output_components == 1) && (jpeg_info.quantize_colors == 0))
     {
@@ -2311,7 +2310,6 @@ static MagickBooleanType WriteJPEGImage(const ImageInfo *image_info,
             Perform optimization only if available memory resources permit it.
           */
           status=AcquireMagickResource(MemoryResource,length);
-          RelinquishMagickResource(MemoryResource,length);
           jpeg_info.optimize_coding=status == MagickFalse ? FALSE : TRUE;
         }
     }