From: Cristy Date: Sat, 11 May 2019 12:26:39 +0000 (-0400) Subject: https://github.com/ImageMagick/ImageMagick/issues/1540 X-Git-Tag: 7.0.8-45~12 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7dbf5b259e39e76197035e1e58d8392d4712d1b1;p=imagemagick https://github.com/ImageMagick/ImageMagick/issues/1540 --- diff --git a/MagickCore/quantize.c b/MagickCore/quantize.c index 55158aa1a..9f3124718 100644 --- a/MagickCore/quantize.c +++ b/MagickCore/quantize.c @@ -2201,10 +2201,8 @@ MagickExport MagickBooleanType GetImageQuantizeError(Image *image, mean_error, mean_error_per_pixel; - size_t - index; - ssize_t + index, y; assert(image != (Image *) NULL); @@ -2235,7 +2233,7 @@ MagickExport MagickBooleanType GetImageQuantizeError(Image *image, break; for (x=0; x < (ssize_t) image->columns; x++) { - index=GetPixelIndex(image,p); + index=(ssize_t) GetPixelIndex(image,p); if (image->alpha_trait == BlendPixelTrait) { alpha=(double) (QuantumScale*GetPixelAlpha(image,p)); @@ -3318,6 +3316,9 @@ static MagickBooleanType SetGrayscaleImage(Image *image, register ssize_t i; + size_t + extent; + ssize_t *colormap_index, j, @@ -3327,19 +3328,15 @@ static MagickBooleanType SetGrayscaleImage(Image *image, assert(image->signature == MagickCoreSignature); if (image->type != GrayscaleType) (void) TransformImageColorspace(image,GRAYColorspace,exception); - if (image->storage_class == PseudoClass) - colormap_index=(ssize_t *) AcquireQuantumMemory(MagickMax(image->colors+1, - MaxMap),sizeof(*colormap_index)); - else - colormap_index=(ssize_t *) AcquireQuantumMemory(MagickMax(MaxColormapSize+1, - MaxMap),sizeof(*colormap_index)); + extent=MagickMax(image->colors+1,MagickMax(MaxColormapSize,MaxMap+1)); + colormap_index=(ssize_t *) AcquireQuantumMemory(extent, + sizeof(*colormap_index)); if (colormap_index == (ssize_t *) NULL) ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed", image->filename); if (image->storage_class != PseudoClass) { - (void) memset(colormap_index,(-1),MaxColormapSize* - sizeof(*colormap_index)); + (void) memset(colormap_index,(-1),extent*sizeof(*colormap_index)); if (AcquireImageColormap(image,MaxColormapSize,exception) == MagickFalse) { colormap_index=(ssize_t *) RelinquishMagickMemory(colormap_index); @@ -3401,6 +3398,7 @@ static MagickBooleanType SetGrayscaleImage(Image *image, } image_view=DestroyCacheView(image_view); } + (void) memset(colormap_index,0,extent*sizeof(*colormap_index)); for (i=0; i < (ssize_t) image->colors; i++) image->colormap[i].alpha=(double) i; qsort((void *) image->colormap,image->colors,sizeof(PixelInfo), diff --git a/coders/exr.c b/coders/exr.c index cc4697fdf..c0505d39a 100644 --- a/coders/exr.c +++ b/coders/exr.c @@ -266,6 +266,8 @@ static Image *ReadEXRImage(const ImageInfo *image_info,ExceptionInfo *exception) SetPixelViaPixelInfo(image,&image->background_color,q); q+=GetPixelChannels(image); } + if (SyncAuthenticPixels(image,exception) == MagickFalse) + break; continue; } memset(scanline,0,columns*sizeof(*scanline));