summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qarraydata.cpp
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2025-12-01 12:50:08 -0800
committerMarc Mutz <marc.mutz@qt.io>2025-12-09 21:51:10 +0000
commita586505c346bc3e3ed86485d717a9f290bfea33b (patch)
treedaab2b1389f902ae0fc13e52876b83886bdf1c79 /src/corelib/tools/qarraydata.cpp
parentc26310d8305e86412f0341883310546ae9036aa2 (diff)
QArrayData: catch negative capacities earlier
This isn't necessary because we would catch it inside of calculateBlockSize() → qCalculateBlockSize(), because the negative elementCount becomes a large positive one after the conversion to size_t. But since this change is effectively free anyway, we can do it and avoid a future in which those functions don't convert to an unsigned type. Pick-to: 6.11 6.10 Change-Id: I14a1f4f0828ea17ae7bafffdbf2ccddebf54bb2e Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Diffstat (limited to 'src/corelib/tools/qarraydata.cpp')
-rw-r--r--src/corelib/tools/qarraydata.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/corelib/tools/qarraydata.cpp b/src/corelib/tools/qarraydata.cpp
index 1c0371e463e..d173d824e88 100644
--- a/src/corelib/tools/qarraydata.cpp
+++ b/src/corelib/tools/qarraydata.cpp
@@ -162,7 +162,7 @@ allocateHelper(QArrayData **dptr, qsizetype objectSize, qsizetype alignment, qsi
QArrayData::AllocationOption option) noexcept
{
*dptr = nullptr;
- if (capacity == 0)
+ if (capacity <= 0)
return {};
const qsizetype headerSize = calculateHeaderSize(alignment);