Skip to content

Commit

Permalink
DecompressHelper: retain the error from internal counter
Browse files Browse the repository at this point in the history
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.5
Fixes: QTBUG-129697
Change-Id: Ia64e1d13a99b62760f61cac6b67ae3cff5e2c9da
Reviewed-by: Mate Barany <mate.barany@qt.io>
(cherry picked from commit f84c83b)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
  • Loading branch information
Morten242 authored and Qt Cherry-pick Bot committed Oct 9, 2024
1 parent 31367fd commit a7ad264
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/network/access/qdecompresshelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 :|
}
}

/*!
Expand All @@ -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 :|
}
}

/*!
Expand All @@ -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 :|
}
}

/*!
Expand Down Expand Up @@ -552,8 +561,6 @@ void QDecompressHelper::clear()
totalBytesRead = 0;
totalUncompressedBytes = 0;
totalCompressedBytes = 0;

errorStr.clear();
}

qsizetype QDecompressHelper::readZLib(char *data, const qsizetype maxSize)
Expand Down

0 comments on commit a7ad264

Please sign in to comment.