summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools
diff options
context:
space:
mode:
authorIvan Solovev <ivan.solovev@qt.io>2021-07-07 14:51:36 +0200
committerIvan Solovev <ivan.solovev@qt.io>2021-07-08 14:41:14 +0200
commit82499f81478032911d8f788aa28e8d780b31c973 (patch)
tree5de5dedfb0d594078ec103a6b0daa82161765533 /src/corelib/tools
parent0ac8722d25503a74fe8aed3e6129bc5fd5de9447 (diff)
QMultiHash::find - prevent detaching shared null
Do not detach when find(key, value) is called on an empty QMultiHash. As a drive-by: fix return value for QMultiHash::remove() in case of empty QMultiHash. Task-number: QTBUG-91736 Pick-to: 6.2 6.1 Change-Id: I1e32f359e7ee9ce8403dae79d02e0b88a20ec4a5 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/corelib/tools')
-rw-r--r--src/corelib/tools/qhash.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/corelib/tools/qhash.h b/src/corelib/tools/qhash.h
index 392371ce5e..6866dfebf3 100644
--- a/src/corelib/tools/qhash.h
+++ b/src/corelib/tools/qhash.h
@@ -1782,7 +1782,7 @@ public:
qsizetype remove(const Key &key, const T &value)
{
if (isEmpty()) // prevents detaching shared null
- return false;
+ return 0;
detach();
auto it = d->find(key);
@@ -1844,6 +1844,8 @@ public:
iterator find(const Key &key, const T &value)
{
+ if (isEmpty())
+ return end();
detach();
auto it = constFind(key, value);
return iterator(it.i, it.e);