summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorMårten Nordheim <marten.nordheim@qt.io>2020-12-08 15:47:47 +0100
committerMårten Nordheim <marten.nordheim@qt.io>2020-12-16 14:54:17 +0100
commit0ca46358321f2244386b0b6558a915cda8c6c006 (patch)
tree9ab4d20910b796345f052a4b623f6d40be706f3d /src/corelib
parentac210c73e43621f942d3cb947eef036fc5e7646e (diff)
QCache: fix updating entries breaking the internal chain
After f08492c6fd9818c7d80b1725355453e179b4d85b was merged this bug would manifest as an entry appearing twice in the chain when a updating an existing entry (insert with an existing key). This could sometimes result in crashes later as the list filled up and the list was used in trim() to remove various entries. Fixes: QTBUG-89176 Pick-to: 6.0 Change-Id: Ide80160fb4317dc0aefe79eec5dce7ec6813e790 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/tools/qcache.h9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/corelib/tools/qcache.h b/src/corelib/tools/qcache.h
index 74784af121..41cf9abc46 100644
--- a/src/corelib/tools/qcache.h
+++ b/src/corelib/tools/qcache.h
@@ -247,14 +247,15 @@ public:
if (result.initialized) {
cost -= n->value.cost;
result.it.node()->emplace(object, cost);
+ relink(key);
} else {
Node::createInPlace(n, key, object, cost);
+ n->prev = &chain;
+ n->next = chain.next;
+ chain.next->prev = n;
+ chain.next = n;
}
total += cost;
- n->prev = &chain;
- n->next = chain.next;
- chain.next->prev = n;
- chain.next = n;
return true;
}
T *object(const Key &key) const noexcept