qt6-bb10/tests/auto/corelib/tools
Marc Mutz c6aa399d06 QBitArray: avoid overflow in size-to-storage 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 (size + 7) / 8
logical-to-storage-size calculation by using unsigned arithmetic.

Use the opportunity to Extract Methods storage_size() and
allocation_size(), which differ by one (d[[0] contains the size() mod
8), making it clear what's what.

[ChangeLog][QtCore][QBitArray] Fixed a bug with QBitArrays whose
size() came within 7 of the size_type's maximum.

Pick-to: 6.7 6.6 6.5 6.2 5.15
Change-Id: I5d94bae9c9c210ba1e36f8cf03609125c81bd15d
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2024-01-30 22:28:19 +01:00
..
collections Mark all of Qt as free of Q_FOREACH, except where it isn't 2023-08-19 05:19:42 +00:00
containerapisymmetry tst_containerapisymmetry: remove the extra push_back 2023-12-07 23:55:08 +01:00
qalgorithms CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qarraydata QArrayDataPointer: add an allocating constructor 2023-10-25 12:01:58 -07:00
qatomicscopedvaluerollback Make QAtomicScopedValueRollback public API 2023-12-08 02:24:41 +01:00
qbitarray QBitArray: avoid overflow in size-to-storage calculations 2024-01-30 22:28:19 +01:00
qcache CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qcommandlineparser QCommandLineParser: Warn invalid value calls 2023-09-21 22:05:06 +02:00
qcontiguouscache CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qcryptographichash QCryptographicHash: fallback to non-OpenSSL implementation for Keccak 2023-11-08 18:40:14 +01:00
qduplicatetracker QDuplicateTracker: test with std::string, too 2023-12-11 19:00:16 +00:00
qeasingcurve tests/auto/: port Q_FOREACH to ranged-for, local const containers 2023-08-19 16:29:25 +03:00
qexplicitlyshareddatapointer tst_QExplicitlySharedDataPointer: Remove stray comment 2023-07-25 12:31:04 +02:00
qflatmap CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qfreelist tst_QFreeList: build with QT_NO_FOREACH 2023-08-19 16:29:54 +03:00
qhash Check that QMulti{Map,Hash} (still) store in reverse insertion order 2023-12-07 07:16:23 +02:00
qhashfunctions tst_QHashFunctions: extend the consistency() test with mixed-signedness int types 2024-01-09 08:27:42 +01:00
qhashseed CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qline CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qlist Make QAtomicScopedValueRollback public API 2023-12-08 02:24:41 +01:00
qmacautoreleasepool CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qmakearray CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qmap Check that QMulti{Map,Hash} (still) store in reverse insertion order 2023-12-07 07:16:23 +02:00
qmargins CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qmessageauthenticationcode CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qoffsetstringarray CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qpair CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qpoint CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qpointf CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qqueue CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qrect CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qringbuffer CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qscopedpointer CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qscopedvaluerollback CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qscopeguard tst_QScopeGuard: test if and how guard in optional<> works 2023-07-10 19:47:08 +00:00
qset Optimize QSet::unite 2024-01-20 08:55:06 +00:00
qsharedpointer QSP/QWP: introduce owner_before, owner_equal, owner_hash 2023-10-26 19:24:40 +02:00
qsize CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qsizef CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qspan QSpan: make adl_begin() etc SFINAE-friendly 2024-01-26 23:50:57 +01:00
qstl CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qtaggedpointer CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qtimeline CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qtyperevision Dissociate QTypeRevision from QVersionNumber 2024-01-10 02:25:24 +00:00
quniquehandle Add QUniqueHandle - a general purpose RAII wrapper for non-memory types 2023-11-15 05:01:51 +01:00
qvarlengtharray CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qversionnumber Dissociate QTypeRevision from QVersionNumber 2024-01-10 02:25:24 +00:00
CMakeLists.txt Dissociate QTypeRevision from QVersionNumber 2024-01-10 02:25:24 +00:00