From 6b4e0c5803b4b8b4396791ba436d9692195993d6 Mon Sep 17 00:00:00 2001 From: Fabian Kosmale Date: Fri, 25 Sep 2020 15:45:28 +0200 Subject: 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 --- src/corelib/kernel/qproperty.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/corelib/kernel/qproperty.cpp') 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) -- cgit v1.2.3