DecompressHelper: retain the error from internal counter

We never copied the error string so after the call to 'clear' it went
away completely. Additionally, stop clearing the error string in clear()
since we reset it when the encoding is set, in case the object is
reused.

Pick-to: 6.8 6.5
Fixes: QTBUG-129697
Change-Id: Ia64e1d13a99b62760f61cac6b67ae3cff5e2c9da
Reviewed-by: Mate Barany <mate.barany@qt.io>
This commit is contained in:
Mårten Nordheim 2024-10-07 16:52:10 +02:00
parent 7ad855e51e
commit f84c83be52

View File

@ -234,8 +234,11 @@ void QDecompressHelper::feed(QByteArray &&data)
Q_ASSERT(contentEncoding != None);
totalCompressedBytes += data.size();
compressedDataBuffer.append(std::move(data));
if (!countInternal(compressedDataBuffer[compressedDataBuffer.bufferCount() - 1]))
if (!countInternal(compressedDataBuffer[compressedDataBuffer.bufferCount() - 1])) {
if (errorStr.isEmpty() && countHelper)
errorStr = countHelper->errorString();
clear(); // If our counting brother failed then so will we :|
}
}
/*!
@ -247,8 +250,11 @@ void QDecompressHelper::feed(const QByteDataBuffer &buffer)
Q_ASSERT(contentEncoding != None);
totalCompressedBytes += buffer.byteAmount();
compressedDataBuffer.append(buffer);
if (!countInternal(buffer))
if (!countInternal(buffer)) {
if (errorStr.isEmpty() && countHelper)
errorStr = countHelper->errorString();
clear(); // If our counting brother failed then so will we :|
}
}
/*!
@ -261,8 +267,11 @@ void QDecompressHelper::feed(QByteDataBuffer &&buffer)
totalCompressedBytes += buffer.byteAmount();
const QByteDataBuffer copy(buffer);
compressedDataBuffer.append(std::move(buffer));
if (!countInternal(copy))
if (!countInternal(copy)) {
if (errorStr.isEmpty() && countHelper)
errorStr = countHelper->errorString();
clear(); // If our counting brother failed then so will we :|
}
}
/*!
@ -552,8 +561,6 @@ void QDecompressHelper::clear()
totalBytesRead = 0;
totalUncompressedBytes = 0;
totalCompressedBytes = 0;
errorStr.clear();
}
qsizetype QDecompressHelper::readZLib(char *data, const qsizetype maxSize)