summaryrefslogtreecommitdiffstats
path: root/src/corelib/text/qbytearray.cpp
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2022-09-20 09:17:31 +0200
committerMarc Mutz <marc.mutz@qt.io>2022-09-26 17:00:30 +0200
commitfb9213e640b9b5612fd198b1d859d00a28642672 (patch)
treeee4375c97f1963c25f356de6179de99aab133d21 /src/corelib/text/qbytearray.cpp
parent98d9cfabc19984d75951f7ee66037331da63c0b8 (diff)
qCompress: use saturation, not truncation, for the size header
This provides a better size hint than the pseudo-random mod 4GiB number used before. In particular, it will make the Qt 5 implementation fail fast, because UINT_MAX will be recognized as a non-representable size right away. Pick-to: 6.4 6.3 6.2 Task-number: QTBUG-104972 Change-Id: I6010f558eb71bbf02fb0f71bee1b3b1a15ec6e3f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/text/qbytearray.cpp')
-rw-r--r--src/corelib/text/qbytearray.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/corelib/text/qbytearray.cpp b/src/corelib/text/qbytearray.cpp
index fb55c630bf..33292d9ca2 100644
--- a/src/corelib/text/qbytearray.cpp
+++ b/src/corelib/text/qbytearray.cpp
@@ -603,7 +603,7 @@ QByteArray qCompress(const uchar* data, qsizetype nbytes, int compressionLevel)
switch (res) {
case Z_OK:
bazip.resize(len + HeaderSize);
- qToBigEndian(CompressSizeHint_t(nbytes), bazip.data());
+ qToBigEndian(qt_saturate<CompressSizeHint_t>(nbytes), bazip.data());
break;
case Z_MEM_ERROR:
return tooMuchData(ZLibOp::Compression);