From: Dirk Lemstra Date: Thu, 11 Jul 2019 18:56:13 +0000 (+0200) Subject: Only set the quantum type once. X-Git-Tag: 7.0.8-54~64 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6e220087f5006df9077450891866c48904fb679d;p=imagemagick Only set the quantum type once. --- diff --git a/coders/pnm.c b/coders/pnm.c index 5849388dc..16703bdff 100644 --- a/coders/pnm.c +++ b/coders/pnm.c @@ -300,7 +300,7 @@ static Image *ReadPNMImage(const ImageInfo *image_info,ExceptionInfo *exception) if ((count != 1) || (format != 'P')) ThrowPNMException(CorruptImageError,"ImproperImageHeader"); max_value=1; - quantum_type=RGBQuantum; + quantum_type=UndefinedQuantum; quantum_scale=1.0; format=(char) ReadBlobByte(image); if (format != '7') @@ -386,7 +386,8 @@ static Image *ReadPNMImage(const ImageInfo *image_info,ExceptionInfo *exception) image->rows=StringToUnsignedLong(value); if (LocaleCompare(keyword,"maxval") == 0) max_value=StringToUnsignedLong(value); - if (LocaleCompare(keyword,"TUPLTYPE") == 0) + if ((quantum_type == UndefinedQuantum) && + (LocaleCompare(keyword,"TUPLTYPE") == 0)) { if (LocaleCompare(value,"BLACKANDWHITE") == 0) { @@ -431,6 +432,8 @@ static Image *ReadPNMImage(const ImageInfo *image_info,ExceptionInfo *exception) image->columns=StringToUnsignedLong(value); } } + if (quantum_type == UndefinedQuantum) + quantum_type=RGBQuantum; if ((image->columns == 0) || (image->rows == 0)) ThrowPNMException(CorruptImageError,"NegativeOrZeroImageSize"); if ((max_value == 0) || (max_value > 4294967295UL))