summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorZhang Yu <zhangyub@uniontech.com>2020-12-30 10:57:09 +0800
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-01-06 03:06:52 +0000
commit7b356d73671fb7b097399bcde9d8855264625dac (patch)
tree46a5df1f4677c9bb820ac4be824f2cea75848593 /tests
parent91a97187ac385c24344d1d062abe7c9d7611c1c4 (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 Change-Id: I10c3d196cbc72aed8c8c922ef16534bba51037b7 Reviewed-by: Lars Knoll <lars.knoll@qt.io> (cherry picked from commit 22416ecaaf58619c716229b71cdca558fda0a861) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/corelib/tools/qhash/tst_qhash.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/tests/auto/corelib/tools/qhash/tst_qhash.cpp b/tests/auto/corelib/tools/qhash/tst_qhash.cpp
index f61dfda720..5389758b5f 100644
--- a/tests/auto/corelib/tools/qhash/tst_qhash.cpp
+++ b/tests/auto/corelib/tools/qhash/tst_qhash.cpp
@@ -1731,6 +1731,13 @@ void tst_QHash::equal_range()
QVERIFY(p2.first == cm1.cbegin() || p2.second == cm1.cend());
}
+ {
+ const QMultiHash<int, int> cm2;
+ auto p1 = cm2.equal_range(0);
+ QVERIFY(p1.first == cm2.end());
+ QVERIFY(p1.second == cm2.end());
+ }
+
QMultiHash<int, int> h2;
for (int i = 0; i < 8; ++i)
for (int j = 0; j < 8; ++j)