From 6d095e5ac0504dc2386f9377276152b381ed8761 Mon Sep 17 00:00:00 2001 From: Cristy Date: Wed, 21 Aug 2019 11:59:46 -0400 Subject: [PATCH] Eliminate possible buffer overflow --- coders/png.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/coders/png.c b/coders/png.c index e61e09f29..e61b1713c 100644 --- a/coders/png.c +++ b/coders/png.c @@ -11400,14 +11400,15 @@ static MagickBooleanType WriteOnePNGImage(MngInfo *mng_info, (void) SetQuantumEndian(image,quantum_info,MSBEndian); num_passes=png_set_interlace_handling(ping); - if ((!mng_info->write_png8 && !mng_info->write_png24 && - !mng_info->write_png48 && !mng_info->write_png64 && - !mng_info->write_png32) && - (mng_info->IsPalette || - (image_info->type == BilevelType)) && - image_matte == MagickFalse && - ping_have_non_bw == MagickFalse) - { + if ((mng_info->write_png_colortype-1 == PNG_COLOR_TYPE_PALETTE) || + ((!mng_info->write_png8 && !mng_info->write_png24 && + !mng_info->write_png48 && !mng_info->write_png64 && + !mng_info->write_png32) && + (mng_info->IsPalette || + (image_info->type == BilevelType)) && + image_matte == MagickFalse && + ping_have_non_bw == MagickFalse)) + { /* Palette, Bilevel, or Opaque Monochrome */ QuantumType quantum_type; -- 2.40.0