From d7d0418dd0afcd0b9948254cd6e88a8f6c9f051e Mon Sep 17 00:00:00 2001 From: glennrp Date: Fri, 25 Feb 2011 04:20:48 +0000 Subject: [PATCH] Make sure image->colormap isn't NULL before we read it. --- coders/png.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/coders/png.c b/coders/png.c index 58355c885..bd49b1204 100644 --- a/coders/png.c +++ b/coders/png.c @@ -7477,7 +7477,8 @@ static MagickBooleanType WriteOnePNGImage(MngInfo *mng_info, if (SyncAuthenticPixels(image,exception) == MagickFalse) break; - if (image->colors != 0 && image->colors <= 256) + if (image_colors != 0 && image_colors <= 256 && + image->colormap != NULL) for (i=0; icolormap[i].opacity = image->colormap[i].opacity > OpaqueOpacity/2 ? 0 : @@ -7490,7 +7491,8 @@ static MagickBooleanType WriteOnePNGImage(MngInfo *mng_info, * quantization of the pixels and background color to the 3-3-2 * palette. */ - if (image_colors == 0 || image_colors > 256) + if (image_colors != 0 && image_colors <= 256 && + image->colormap != NULL) { if (logging != MagickFalse) (void) LogMagickEvent(CoderEvent,GetMagickModule(), @@ -7546,7 +7548,8 @@ static MagickBooleanType WriteOnePNGImage(MngInfo *mng_info, break; } - if (image_colors != 0 && image_colors <= 256) + if (image_colors != 0 && image_colors <= 256 && + image->colormap != NULL) { if (logging != MagickFalse) (void) LogMagickEvent(CoderEvent,GetMagickModule(), -- 2.40.0