summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/corelib/tools/qhash.h3
-rw-r--r--tests/auto/corelib/tools/qhash/tst_qhash.cpp7
2 files changed, 10 insertions, 0 deletions
diff --git a/src/corelib/tools/qhash.h b/src/corelib/tools/qhash.h
index 70e98bed60..f7f9178c98 100644
--- a/src/corelib/tools/qhash.h
+++ b/src/corelib/tools/qhash.h
@@ -1849,6 +1849,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());
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)