diff options
author | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2020-10-15 02:32:00 +0200 |
---|---|---|
committer | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2020-10-16 01:08:00 +0200 |
commit | ef1905aebc4c4961c859bd781398dc6cea89d3a0 (patch) | |
tree | 5ac7cab6bc5d612d3dc2c672d62a5dd8c0e983b7 /src | |
parent | 9f1e1eb5524fbf27a9fd2db4f1d98bb2bcd90077 (diff) |
QMultiHash: fix operator==
An empty QMultiHash can still have an allocated dpointer, so we
can't desume that two hashes are different because one has a
dpointer and the other doesn't. Compares the sizes first, and
infer that equal size, and non-zero size, mean both have a dpointer.
Fixes: QTBUG-87575
Change-Id: I2e206bd071c02fb8970a4e77f8b0d29ad7e58bbe
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/tools/qhash.h | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/corelib/tools/qhash.h b/src/corelib/tools/qhash.h index c6b82dbd33..046dbddb57 100644 --- a/src/corelib/tools/qhash.h +++ b/src/corelib/tools/qhash.h @@ -1229,9 +1229,14 @@ public: { if (d == other.d) return true; - if (!d || ! other.d) + if (m_size != other.m_size) return false; - if (m_size != other.m_size || d->size != other.d->size) + if (m_size == 0) + return true; + // equal size, and both non-zero size => d pointers allocated for both + Q_ASSERT(d); + Q_ASSERT(other.d); + if (d->size != other.d->size) return false; for (auto it = other.d->begin(); it != other.d->end(); ++it) { auto i = d->find(it.node()->key); |