diff options
author | Zhang Yu <zhangyub@uniontech.com> | 2020-12-30 10:57:09 +0800 |
---|---|---|
committer | Zhang Yu <zhangyub@uniontech.com> | 2021-01-06 09:07:10 +0800 |
commit | 22416ecaaf58619c716229b71cdca558fda0a861 (patch) | |
tree | 36d8fd21fed60e29aec9cc1e2199f4f52b65e925 /src/corelib/tools/qhash.h | |
parent | 13f9e2857bce165de0fff2c7dd25bd4155566801 (diff) |
Fix QMultiHash::equal_range crashes
QMultiHash::equal_range crashes when called in a const member function.
The Data `d` is a NULL pointer when calling equal_range()
before inserting data into an empty QMultiHash.
Then calling`d->find` crashes.
Fixes: QTBUG-89687
Pick-to: 6.0
Change-Id: I10c3d196cbc72aed8c8c922ef16534bba51037b7
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/corelib/tools/qhash.h')
-rw-r--r-- | src/corelib/tools/qhash.h | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/corelib/tools/qhash.h b/src/corelib/tools/qhash.h index 4b4235aa99..b3c389903a 100644 --- a/src/corelib/tools/qhash.h +++ b/src/corelib/tools/qhash.h @@ -1901,6 +1901,9 @@ public: QPair<const_iterator, const_iterator> equal_range(const Key &key) const noexcept { + if (!d) + return qMakePair(end(), end()); + auto it = d->find(key); if (it.isUnused()) return qMakePair(end(), end()); |