summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndrei Golubev <andrei.golubev@qt.io>2021-03-11 10:01:04 +0100
committerAndrei Golubev <andrei.golubev@qt.io>2021-03-12 15:44:26 +0100
commit341654213bfd02a448490212e3b9b0d2027dfd2f (patch)
treebb4abc4704332715126e1f15e73789d24fe2449c /src
parent4e1c5d980d34f6dd4cb08a875e298db1be1ec21e (diff)
Fix QMultiHash::count(key) crash
As QMultiHash uses a pointer for the data, nullptr dereference is a thing, so check for valid d before doing anything in count() Fixes: QTBUG-91704 Change-Id: Ia20440cd7bdc03cb09c77f796fb9c5b52765eac5 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit f226854d256a382a5cc7ff08b10a0d27fbefb0fe) Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/corelib/tools/qhash.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/corelib/tools/qhash.h b/src/corelib/tools/qhash.h
index f7f9178c98..fbf9b5b5f8 100644
--- a/src/corelib/tools/qhash.h
+++ b/src/corelib/tools/qhash.h
@@ -1754,6 +1754,8 @@ public:
qsizetype count(const Key &key) const noexcept
{
+ if (!d)
+ return 0;
auto it = d->find(key);
if (it.isUnused())
return 0;
@@ -1769,6 +1771,8 @@ public:
qsizetype count(const Key &key, const T &value) const noexcept
{
+ if (!d)
+ return 0;
auto it = d->find(key);
if (it.isUnused())
return 0;