summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2022-07-18 09:28:20 +0200
committerMarc Mutz <marc.mutz@qt.io>2022-08-04 03:35:36 +0200
commit011b68d3cd95295890b1ed724aa4331ff5680eed (patch)
treea2c7cccf195ef53bdb91f70d7f29b41b8e7998cf /src
parent046a5a8f4f49944e6bf94cded52f88535d16bb3f (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. Pick-to: 6.4 6.3 6.2 Change-Id: Ia9db7acbfa47e601b466d6cc6a728859065c27b5 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
Diffstat (limited to 'src')
-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 819dd46315..2f4197d775 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();