From 2aea982e9eab59342a230e6a6629f6ad90e5822f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Novomesk=C3=BD?= Date: Tue, 29 Aug 2023 16:22:52 +0200 Subject: [PATCH] qoi: fix reports from quality scanner MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit struct QoiHeader is initialized to invalid values prior use, it’s good to detect situations when we read incomplete data. Add include in scanlineconverter.cpp so it can be used without change in kf5 branch. --- src/imageformats/qoi.cpp | 6 +++--- src/imageformats/scanlineconverter.cpp | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/imageformats/qoi.cpp b/src/imageformats/qoi.cpp index be0e7ce..1323528 100644 --- a/src/imageformats/qoi.cpp +++ b/src/imageformats/qoi.cpp @@ -141,7 +141,7 @@ static bool LoadQOI(QIODevice *device, const QoiHeader &qoi, QImage &img) quint64 chunks_len = ba.size() - QOI_END_STREAM_PAD; quint64 p = 0; - QRgb *scanline = (QRgb *)img.scanLine(y); + QRgb *scanline = reinterpret_cast(img.scanLine(y)); const quint8 *input = reinterpret_cast(ba.constData()); for (quint32 x = 0; x < qoi.Width; ++x) { if (run > 0) { @@ -328,7 +328,7 @@ bool QOIHandler::canRead(QIODevice *device) QDataStream stream(head); stream.setByteOrder(QDataStream::BigEndian); - QoiHeader qoi; + QoiHeader qoi = {0, 0, 0, 0, 2}; stream >> qoi; return IsSupported(qoi); @@ -340,7 +340,7 @@ bool QOIHandler::read(QImage *image) s.setByteOrder(QDataStream::BigEndian); // Read image header - QoiHeader qoi; + QoiHeader qoi = {0, 0, 0, 0, 2}; s >> qoi; // Check if file is supported diff --git a/src/imageformats/scanlineconverter.cpp b/src/imageformats/scanlineconverter.cpp index cd19d7a..77a397a 100644 --- a/src/imageformats/scanlineconverter.cpp +++ b/src/imageformats/scanlineconverter.cpp @@ -5,6 +5,7 @@ */ #include "scanlineconverter_p.h" +#include ScanLineConverter::ScanLineConverter(const QImage::Format &targetFormat) : _targetFormat(targetFormat)