From: Cristy Date: Fri, 24 Nov 2017 16:26:57 +0000 (-0500) Subject: Proper resource bookkeeping X-Git-Tag: 7.0.7-12~24 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=196ce543c76fab0a7de47d2a6268cc76ad253123;p=imagemagick Proper resource bookkeeping --- diff --git a/MagickCore/cache.c b/MagickCore/cache.c index dae3aa8d7..926fe0f73 100644 --- a/MagickCore/cache.c +++ b/MagickCore/cache.c @@ -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)) diff --git a/MagickCore/resource.c b/MagickCore/resource.c index 28980000e..31a0bde99 100644 --- a/MagickCore/resource.c +++ b/MagickCore/resource.c @@ -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); } diff --git a/coders/jpeg.c b/coders/jpeg.c index a24be9199..dd3450d09 100644 --- a/coders/jpeg.c +++ b/coders/jpeg.c @@ -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; } }