summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMårten Nordheim <marten.nordheim@qt.io>2021-10-26 13:34:38 +0200
committerMårten Nordheim <marten.nordheim@qt.io>2021-10-26 21:56:31 +0200
commit323b97ccaea7b9442fa1bcb01514e0c5a4a97fdc (patch)
tree3c1d4bae88125c1294c3f71736ce93cb64869bb3 /src
parente3f05981cbeb0b7721f960ef88effa77be2af5ce (diff)
QHash: avoid crashing when reserving on a shared hash
Pick-to: 6.2 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>
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 ecbdfe4fb8..49c9ce1d41 100644
--- a/src/corelib/tools/qhash.h
+++ b/src/corelib/tools/qhash.h
@@ -500,8 +500,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))