From d4918186d7878f623a72cf0efad0732b0bd0b814 Mon Sep 17 00:00:00 2001 From: Ana Bobillo Date: Mon, 9 Nov 2026 14:44:59 +0000 Subject: [PATCH] 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. --- src/imageformats/psd.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/imageformats/psd.cpp b/src/imageformats/psd.cpp index afa10b9..b047b64 100644 --- a/src/imageformats/psd.cpp +++ b/src/imageformats/psd.cpp @@ -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) {