summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2022-07-18 09:28:20 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-08-04 11:18:06 +0000
commita4b3fc4121fba63307edfd2bce78a4994fbe7ef0 (patch)
tree0f164bee7b59738e4cf71cf64ee4970986423704
parenta905c3e68342629e5d5ec2e3d9ec862b730087b4 (diff)
QByteDataBuffer: assert an undocumented precondition
The alternative would be to return a null QByteArray, but the current implementation makes calling read() on an empty QByteDataBuffer UB, so this is behavior-preserving, just with a bit nicer error message. Change-Id: Ia9db7acbfa47e601b466d6cc6a728859065c27b5 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io> (cherry picked from commit 011b68d3cd95295890b1ed724aa4331ff5680eed) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/corelib/text/qbytedata_p.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/corelib/text/qbytedata_p.h b/src/corelib/text/qbytedata_p.h
index 946f9155ff..46eee13ccd 100644
--- a/src/corelib/text/qbytedata_p.h
+++ b/src/corelib/text/qbytedata_p.h
@@ -105,6 +105,7 @@ public:
// preferably use this function to read data.
inline QByteArray read()
{
+ Q_ASSERT(!isEmpty());
squeezeFirst();
bufferCompleteSize -= buffers.first().size();
return buffers.takeFirst();