aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2020-05-20 17:23:13 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2020-06-02 08:52:40 +0000
commitb4d4c4773d95b8b770b359594966162339c1bd7f (patch)
tree633eb32d3e1778097b5f8b52d7e96cf76178f1ee
parent9bd647885138cf15b4578f3f7311110bf6f36282 (diff)
Rephrase Chunk::sortIntoBins() for more clarity
Assigning -1 to a quintptr so that it later overflows in another place when adding 1 warrants a comment. Also, assert against i overflowing the bitmaps. This way coverity might also understand what we are doing. Coverity-Id: 175402 Change-Id: I212110cbb784f89b1865bd0c0cc775c08cd40c04 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit 1c928f65ab9c7a495f84943ba1264acb4dbca0b8) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/qml/memory/qv4mm.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/qml/memory/qv4mm.cpp b/src/qml/memory/qv4mm.cpp
index 342e31da1b..7286b0ad27 100644
--- a/src/qml/memory/qv4mm.cpp
+++ b/src/qml/memory/qv4mm.cpp
@@ -473,12 +473,15 @@ void Chunk::sortIntoBins(HeapItem **bins, uint nBins)
uint freeStart = i*Bits + index;
usedSlots &= ~((static_cast<quintptr>(1) << index) - 1);
while (!usedSlots) {
- ++i;
- if (i == EntriesInBitmap) {
- usedSlots = (quintptr)-1;
+ if (++i < EntriesInBitmap) {
+ usedSlots = (objectBitmap[i]|extendsBitmap[i]);
+ } else {
+ Q_ASSERT(i == EntriesInBitmap);
+ // Overflows to 0 when counting trailing zeroes above in next iteration.
+ // Then, all the bits are zeroes and we break.
+ usedSlots = std::numeric_limits<quintptr>::max();
break;
}
- usedSlots = (objectBitmap[i]|extendsBitmap[i]);
#ifndef QT_NO_DEBUG
allocatedSlots += qPopulationCount(usedSlots);
// qDebug() << hex << " i=" << i << "used=" << usedSlots;