qoi: fix reports from quality scanner

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.
This commit is contained in:
Daniel Novomeský 2023-08-29 16:22:52 +02:00
parent 9173f02ea3
commit 2aea982e9e
2 changed files with 4 additions and 3 deletions

View File

@ -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<QRgb *>(img.scanLine(y));
const quint8 *input = reinterpret_cast<const quint8 *>(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

View File

@ -5,6 +5,7 @@
*/
#include "scanlineconverter_p.h"
#include <cstring>
ScanLineConverter::ScanLineConverter(const QImage::Format &targetFormat)
: _targetFormat(targetFormat)