PSD: refuse one-channel grayscale images that announce an alpha channel

A grayscale image with one channel, whose resources announce an alpha channel (Alpha Identifiers), was loaded as RGBA: the alpha of each pixel was read from the gray of the next one, and for the last pixel of each line from past the end of the decoded line, a value never set. Such a file is malformed, so it is now refused.
This commit is contained in:
Ana Bobillo
2026-11-09 14:44:59 +00:00
committed by Albert Astals Cid
parent 5b0ed96ea9
commit d4918186d7
+4
View File
@@ -632,6 +632,10 @@ static QImage::Format imageFormat(const PSDHeader &header, bool alpha)
}
break;
case CM_GRAYSCALE:
if (alpha && header.channel_count < 2) {
// the alpha channel announced is not in the file
break;
}
if (header.depth == 32) {
format = !alpha ? QImage::Format_RGBX32FPx4 : QImage::Format_RGBA32FPx4_Premultiplied;
} else if (header.depth == 16) {