diff options
| author | Marc Mutz <marc.mutz@qt.io> | 2024-01-30 11:15:13 +0100 |
|---|---|---|
| committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2024-02-08 06:40:20 +0000 |
| commit | e576d50d7cff3cacff6de576829577f391214e4b (patch) | |
| tree | 183601218728019a4c379066375e1003fac5461f /tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp | |
| parent | e69a151573e34d2dec34fd41d1ab0d833d7a6fa2 (diff) | |
QBitArray: avoid overflow in storage-to-size calculations
Unlike other containers, a QBitArray's size() is not limited by
storage, but, esp. on 32-bit platforms, its size_type: A INT_MAX
size() QBitArray only requires 256MiB of storage.
So we can't rely on "won't happen in practice" here and need to avoid
the potential UB (signed overflow) in the (d.size() * 8 - *d.data())
storage-to-logical-size calculation by using unsigned arithmetic.
Use the opportunity to Extract Method adjust_head_and_tail(),
centralizing the bit fiddling.
Pick-to: 6.6 6.5 6.2 5.15
Change-Id: I485eafdf3ce2087a81c683672ff98a43f97c9968
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 78f8dfc5427457783ceef7d85885cddbec035ebe)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp')
0 files changed, 0 insertions, 0 deletions
