summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorAndrei Golubev <andrei.golubev@qt.io>2021-03-11 10:01:04 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-03-14 20:34:04 +0000
commit3c224d11228f2560d99078d5f0bf91237657def1 (patch)
tree132c708b8c2eebe5ab67955e42c7804650b5d3f8 /src/corelib
parent0680c87856da963573a4463ea99caf1fd2abf328 (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: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src/corelib')
-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 b3c389903a..4fb68ba0b5 100644
--- a/src/corelib/tools/qhash.h
+++ b/src/corelib/tools/qhash.h
@@ -1806,6 +1806,8 @@ public:
qsizetype count(const Key &key) const noexcept
{
+ if (!d)
+ return 0;
auto it = d->find(key);
if (it.isUnused())
return 0;
@@ -1821,6 +1823,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;