diff options
author | Fabian Kosmale <fabian.kosmale@qt.io> | 2020-09-25 15:45:28 +0200 |
---|---|---|
committer | Fabian Kosmale <fabian.kosmale@qt.io> | 2020-09-29 20:32:32 +0200 |
commit | 6b4e0c5803b4b8b4396791ba436d9692195993d6 (patch) | |
tree | a822ce5bfcd8c44f83f12dead974cc4f4e1d153f /src/corelib/kernel/qproperty.cpp | |
parent | 7a41b928d415b69635abeff13a3a6d205386652f (diff) |
QProperty: fix QBindingStoragePrivate::reallocate related code
In the internal hash map implementation, we have to ensure that the
index is in the interval [0, size - 1].
Moreover, in setBinding we have to refetch the binding storage in case a
reallocation happened.
Change-Id: I11c6264f16537699c8908b647e2355a39ce87648
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/corelib/kernel/qproperty.cpp')
-rw-r--r-- | src/corelib/kernel/qproperty.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/corelib/kernel/qproperty.cpp b/src/corelib/kernel/qproperty.cpp index 81871587e8..4fdf0d8100 100644 --- a/src/corelib/kernel/qproperty.cpp +++ b/src/corelib/kernel/qproperty.cpp @@ -1388,7 +1388,8 @@ struct QBindingStoragePrivate for (size_t i = 0; i < d->size; ++i, ++p) { if (p->data) { Pair *pp = pairs(newData); - size_t index = qHash(p->data); + Q_ASSERT(newData->size && (newData->size & (newData->size - 1)) == 0); // size is a power of two + size_t index = qHash(p->data) & (newData->size - 1); while (pp[index].data) { ++index; if (index == newData->size) |