From c111ed9b035532c2c81ea569f2d22fded9517287 Mon Sep 17 00:00:00 2001 From: Cristy Date: Mon, 8 Apr 2019 18:36:29 -0400 Subject: [PATCH] https://github.com/ImageMagick/ImageMagick/issues/1540 --- MagickCore/quantize.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/MagickCore/quantize.c b/MagickCore/quantize.c index b5fb316ef..55158aa1a 100644 --- a/MagickCore/quantize.c +++ b/MagickCore/quantize.c @@ -3328,11 +3328,11 @@ static MagickBooleanType SetGrayscaleImage(Image *image, if (image->type != GrayscaleType) (void) TransformImageColorspace(image,GRAYColorspace,exception); if (image->storage_class == PseudoClass) - colormap_index=(ssize_t *) AcquireQuantumMemory(image->colors+1, - sizeof(*colormap_index)); + colormap_index=(ssize_t *) AcquireQuantumMemory(MagickMax(image->colors+1, + MaxMap),sizeof(*colormap_index)); else - colormap_index=(ssize_t *) AcquireQuantumMemory(MaxColormapSize+1, - sizeof(*colormap_index)); + colormap_index=(ssize_t *) AcquireQuantumMemory(MagickMax(MaxColormapSize+1, + MaxMap),sizeof(*colormap_index)); if (colormap_index == (ssize_t *) NULL) ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed", image->filename); -- 2.40.0