diff options
author | Marc Mutz <marc.mutz@qt.io> | 2022-07-18 09:28:20 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2022-08-05 17:29:27 +0000 |
commit | b422c289e665a9ae2243ec77c8e403c19294e64b (patch) | |
tree | b10bb247915f3210b4e8a7e38aa2f81ef27299e0 | |
parent | 2395c99fd97e1b36abaed8309e784f4655e616aa (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.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/src/corelib/text/qbytedata_p.h b/src/corelib/text/qbytedata_p.h index 3c36085021..6195e56107 100644 --- a/src/corelib/text/qbytedata_p.h +++ b/src/corelib/text/qbytedata_p.h @@ -139,6 +139,7 @@ public: // preferably use this function to read data. inline QByteArray read() { + Q_ASSERT(!isEmpty()); squeezeFirst(); bufferCompleteSize -= buffers.first().size(); return buffers.takeFirst(); |