From: Cristy Date: Sun, 25 Nov 2018 02:43:52 +0000 (-0500) Subject: ... X-Git-Tag: 7.0.8-15~35 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b36fec348256c49819925b46b13a2737bb370665;p=imagemagick ... --- diff --git a/MagickCore/enhance.c b/MagickCore/enhance.c index 56497db7d..c2c5de6e7 100644 --- a/MagickCore/enhance.c +++ b/MagickCore/enhance.c @@ -629,14 +629,14 @@ MagickExport MagickBooleanType CLAHEImage(Image *image,const size_t x_tiles, OffsetInfo tile; - ssize_t - y; - size_t height, n, width; + ssize_t + y; + unsigned short *pixels; @@ -651,16 +651,20 @@ MagickExport MagickBooleanType CLAHEImage(Image *image,const size_t x_tiles, if (TransformImageColorspace(image,LabColorspace,exception) == MagickFalse) return(MagickFalse); status=MagickTrue; - tile.x=(ssize_t) (x_tiles < 2 ? 2 : x_tiles >= MaxCLAHETiles ? - MaxCLAHETiles-1 : x_tiles); - tile.y=(ssize_t) (y_tiles < 2 ? 2 : y_tiles >= MaxCLAHETiles ? - MaxCLAHETiles-1 : y_tiles); + tile.x=(ssize_t) (x_tiles < 2 ? 2 : x_tiles >= MaxCLAHETiles ? MaxCLAHETiles- + 1 : x_tiles); + tile.y=(ssize_t) (y_tiles < 2 ? 2 : y_tiles >= MaxCLAHETiles ? MaxCLAHETiles- + 1 : y_tiles); width=((image->columns+tile.x/2)/tile.x)*tile.x; height=((image->rows+tile.y/2)/tile.y)*tile.y; pixel_cache=AcquireVirtualMemory(width,height*sizeof(*pixels)); if (pixel_cache == (MemoryInfo *) NULL) - ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed", - image->filename); + { + if (TransformImageColorspace(image,colorspace,exception) == MagickFalse) + return(MagickFalse); + ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed", + image->filename); + } pixels=(unsigned short *) GetVirtualMemoryBlob(pixel_cache); image_view=AcquireVirtualCacheView(image,exception); n=0;