summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qringbuffer.cpp
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2021-12-20 21:52:45 +0100
committerMarc Mutz <marc.mutz@qt.io>2021-12-21 18:14:17 +0100
commit11409f4c023d7a9596ab5c0ca98256f650be9a90 (patch)
tree940f62a4fcf7d27feded4a72e798ead86b1315d9 /src/corelib/tools/qringbuffer.cpp
parent1efae2dcad6b2dbcf4f64e8b9d2963570f561180 (diff)
QStringBuilder: handle freeSpaceAtBegin() in op+=
Amends 9b320edb535a0fbe118933d2e983b73f90c32685. The above commit made the mistake of relying on the 30yr+ old fundamental relation size() - capacity() == freeSpaceAtEnd() which, however, Qt 6's prepend()-optimization (freeSpaceAtBegin()) broke. Because of that, while size() - capacity() may be large enough to hold the new data, if freeSpaceAtBegin() > 0, then freeSpaceAtEnd() may not. Fix by inspecting freeSpaceAtEnd() instead of capacity(). The following reserve() call is unaffected, since it internally already adds freeSpaceAtBegin() to the requested size, which is why the unconditional reserve() in 9b320edb535a0fbe118933d2e983b73f90c32685^ worked while 9b320edb535a0fbe118933d2e983b73f90c32685's capacity() check did not. Fixes: QTBUG-99330 Pick-to: 6.2 6.3 Change-Id: I520f36216011423f97a24484263acd40d8b1fa43 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Topi Reiniƶ <topi.reinio@qt.io> Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
Diffstat (limited to 'src/corelib/tools/qringbuffer.cpp')
0 files changed, 0 insertions, 0 deletions