]> granicus.if.org Git - imagemagick/commitdiff
https://github.com/ImageMagick/ImageMagick/issues/1540
authorCristy <mikayla-grace@urban-warrior.org>
Mon, 8 Apr 2019 22:36:29 +0000 (18:36 -0400)
committerCristy <mikayla-grace@urban-warrior.org>
Mon, 8 Apr 2019 22:36:29 +0000 (18:36 -0400)
MagickCore/quantize.c

index b5fb316ef13e73eb79d5f6f86a514d0dcd21ee94..55158aa1aa6704193bf19a94df94e9d09a4a3a10 100644 (file)
@@ -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);