From: glennrp Date: Wed, 6 Apr 2011 18:07:30 +0000 (+0000) Subject: Remove bogus image->colormap that is passed in to the PNG encoder with a X-Git-Tag: 7.0.1-0~7765 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=28af3713c9111a471cc868c787760de89236fa3c;p=imagemagick Remove bogus image->colormap that is passed in to the PNG encoder with a non-PseudoClass image. --- diff --git a/ChangeLog b/ChangeLog index e0af0b9b6..5d55600ed 100644 --- a/ChangeLog +++ b/ChangeLog @@ -14,6 +14,9 @@ * Make the PNG encoder use depth==8 when incoming image->depth < 8 (the encoder later reduces the depth if it can), to avoid writing an incorrect image. + * Remove any bogus colormap received by the PNG encoder with an image + that is not PseudoClass (reference + http://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=18475). 2011-04-02 6.6.9-3 Cristy * Added -statistic Gradient diff --git a/coders/png.c b/coders/png.c index 67f187df9..32566392c 100644 --- a/coders/png.c +++ b/coders/png.c @@ -7070,6 +7070,16 @@ static MagickBooleanType WriteOnePNGImage(MngInfo *mng_info, (void) LogMagickEvent(CoderEvent,GetMagickModule(), " storage_class=PseudoClass"); } + + if (image->storage_class != PseudoClass && image->colormap != NULL) + { + /* Free the bogus colormap; it can cause trouble later */ + if (logging != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + " Freeing bogus colormap"); + (void *) RelinquishMagickMemory(image->colormap); + image->colormap=NULL; + } if (image->colorspace != RGBColorspace) (void) TransformImageColorspace(image,RGBColorspace);