diff --git a/autotests/read/pcx/16color.pcx b/autotests/read/pcx/16color.pcx new file mode 100644 index 0000000..acd59cc Binary files /dev/null and b/autotests/read/pcx/16color.pcx differ diff --git a/autotests/read/pcx/16color.png b/autotests/read/pcx/16color.png new file mode 100644 index 0000000..0c840bc Binary files /dev/null and b/autotests/read/pcx/16color.png differ diff --git a/src/imageformats/pcx.cpp b/src/imageformats/pcx.cpp index c3ac535..a5d283d 100644 --- a/src/imageformats/pcx.cpp +++ b/src/imageformats/pcx.cpp @@ -308,6 +308,11 @@ static bool readImage4(QImage &img, QDataStream &s, const PCXHEADER &header) return false; } + if (header.BytesPerLine < (header.width() / 8)) { + qWarning() << "PCX image has invalid BytesPerLine value"; + return false; + } + for (int y = 0; y < header.height(); ++y) { if (s.atEnd()) { return false;