summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMÃ¥rten Nordheim <marten.nordheim@qt.io>2021-10-26 13:34:38 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-10-26 21:48:47 +0000
commit61ca8e3111342dafea36f3e2e419f651de544cec (patch)
tree79f3894b3e89ac1c545d87f89512207663e432ec /src
parent448e45b1f4cf9e4883c547d68312c469c79a9cd5 (diff)
QHash: avoid crashing when reserving on a shared hash
Change-Id: I21ad13fa223bd5a2c61112e790965093a2750268 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit 323b97ccaea7b9442fa1bcb01514e0c5a4a97fdc) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src')
-rw-r--r--src/corelib/tools/qhash.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/corelib/tools/qhash.h b/src/corelib/tools/qhash.h
index e6eff78280..f7f37de091 100644
--- a/src/corelib/tools/qhash.h
+++ b/src/corelib/tools/qhash.h
@@ -489,8 +489,9 @@ struct Data
bool resized = numBuckets != other.numBuckets;
size_t nSpans = (numBuckets + Span::LocalBucketMask) / Span::NEntries;
spans = new Span[nSpans];
+ size_t otherNSpans = (other.numBuckets + Span::LocalBucketMask) / Span::NEntries;
- for (size_t s = 0; s < nSpans; ++s) {
+ for (size_t s = 0; s < otherNSpans; ++s) {
const Span &span = other.spans[s];
for (size_t index = 0; index < Span::NEntries; ++index) {
if (!span.hasNode(index))