From 969524ec4d141fc355731adf5b9f31e8d717a933 Mon Sep 17 00:00:00 2001 From: Cristy Date: Mon, 30 Apr 2018 20:20:46 -0400 Subject: [PATCH] ... --- coders/pcx.c | 36 +++++++++++++++--------------------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/coders/pcx.c b/coders/pcx.c index b29b0e8dc..80008e691 100644 --- a/coders/pcx.c +++ b/coders/pcx.c @@ -371,28 +371,22 @@ static Image *ReadPCXImage(const ImageInfo *image_info,ExceptionInfo *exception) if ((pcx_info.bits_per_pixel*pcx_info.planes) >= 64) ThrowPCXException(CorruptImageError,"ImproperImageHeader"); one=1; - if ((pcx_info.bits_per_pixel >= 8) || (pcx_info.planes != 1)) + if ((pcx_info.bits_per_pixel != 8) || (pcx_info.planes == 1)) + if ((pcx_info.version == 3) || (pcx_info.version == 5) || + ((pcx_info.bits_per_pixel*pcx_info.planes) == 1)) + image->colors=(size_t) MagickMin(one << (1UL* + (pcx_info.bits_per_pixel*pcx_info.planes)),256UL); + if (AcquireImageColormap(image,image->colors,exception) == MagickFalse) + ThrowPCXException(ResourceLimitError,"MemoryAllocationFailed"); + if ((pcx_info.bits_per_pixel >= 8) && (pcx_info.planes != 1)) image->storage_class=DirectClass; - else - { - if ((pcx_info.bits_per_pixel != 8) || (pcx_info.planes == 1)) - if ((pcx_info.version == 3) || (pcx_info.version == 5) || - ((pcx_info.bits_per_pixel*pcx_info.planes) == 1)) - image->colors=(size_t) MagickMin(one << (1UL* - (pcx_info.bits_per_pixel*pcx_info.planes)),256UL); - if (AcquireImageColormap(image,image->colors,exception) == MagickFalse) - ThrowPCXException(ResourceLimitError,"MemoryAllocationFailed"); - } - if (image->colors <= 16) - { - p=pcx_colormap; - for (i=0; i < (ssize_t) image->colors; i++) - { - image->colormap[i].red=ScaleCharToQuantum(*p++); - image->colormap[i].green=ScaleCharToQuantum(*p++); - image->colormap[i].blue=ScaleCharToQuantum(*p++); - } - } + p=pcx_colormap; + for (i=0; i < (ssize_t) image->colors; i++) + { + image->colormap[i].red=ScaleCharToQuantum(*p++); + image->colormap[i].green=ScaleCharToQuantum(*p++); + image->colormap[i].blue=ScaleCharToQuantum(*p++); + } pcx_info.bytes_per_line=ReadBlobLSBShort(image); pcx_info.palette_info=ReadBlobLSBShort(image); pcx_info.horizontal_screensize=ReadBlobLSBShort(image); -- 2.40.0