From f84c83be52462536ce5ae5ba68205e7061369fe3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Mon, 7 Oct 2024 16:52:10 +0200 Subject: [PATCH] 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 --- src/network/access/qdecompresshelper.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/network/access/qdecompresshelper.cpp b/src/network/access/qdecompresshelper.cpp index ce9b981909e..764c0260c06 100644 --- a/src/network/access/qdecompresshelper.cpp +++ b/src/network/access/qdecompresshelper.cpp @@ -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)