From: Dirk Lemstra Date: Sun, 4 Mar 2018 21:06:42 +0000 (+0100) Subject: Fixed setting the alpha channel for the merged image in a grayscale image (https... X-Git-Tag: 7.0.7-26~90 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=79de802e7586ab4339b7b81e3d3501d5fcffd57a;p=imagemagick Fixed setting the alpha channel for the merged image in a grayscale image (https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=6008). --- diff --git a/coders/psd.c b/coders/psd.c index dcacb60a1..b41e7d8f2 100644 --- a/coders/psd.c +++ b/coders/psd.c @@ -1093,10 +1093,10 @@ static MagickBooleanType ReadPSDChannelRaw(Image *image,const size_t channels, count=ReadBlob(image,row_size,pixels); if (count != row_size) - { - status=MagickFalse; - break; - } + { + status=MagickFalse; + break; + } status=ReadPSDChannelPixels(image,channels,y,type,pixels,exception); if (status == MagickFalse) @@ -2012,11 +2012,18 @@ static MagickBooleanType ReadPSDMergedImage(const ImageInfo *image_info, status=MagickTrue; for (i=0; i < (ssize_t) psd_info->channels; i++) { + ssize_t + type; + + type=i; + if ((type == 1) && (psd_info->channels == 2)) + type=-1; + if (compression == RLE) - status=ReadPSDChannelRLE(image,psd_info,i,sizes+(i*image->rows), + status=ReadPSDChannelRLE(image,psd_info,type,sizes+(i*image->rows), exception); else - status=ReadPSDChannelRaw(image,psd_info->channels,i,exception); + status=ReadPSDChannelRaw(image,psd_info->channels,type,exception); if (status != MagickFalse) status=SetImageProgress(image,LoadImagesTag,i,psd_info->channels);