diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2019-07-30 16:42:44 +0200 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2019-07-31 09:25:30 +0200 |
commit | 23e605cc5b71f68d6c9e6168053226d027ea46d4 (patch) | |
tree | 1ed5eec7752e81bbdee1395c9db1e34cae1aebe1 | |
parent | 652085c5c2f843b1345e741352b4e2e8328f13fe (diff) | |
download | qtbase-23e605cc5b71f68d6c9e6168053226d027ea46d4.tar.gz |
Plug a memory leak introduced in e24a4976bebd7ca90deac2b40c08900625773
While it is correct not to call the functor when the context object has
been destroyed, we still need ot clean up the slotObj. It's a low-
probability memory leak: the context object has to disappear while
waiting for a host resolution, and for repeated requests for the same
host the cache takes over anyway.
Task-number: QTBUG-76276
Change-Id: Id9daf391353b8252443f3186a7d504d70c553b24
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
-rw-r--r-- | src/network/kernel/qhostinfo_p.h | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/network/kernel/qhostinfo_p.h b/src/network/kernel/qhostinfo_p.h index bbf4cc36d1..fa6529bdfd 100644 --- a/src/network/kernel/qhostinfo_p.h +++ b/src/network/kernel/qhostinfo_p.h @@ -105,12 +105,12 @@ public Q_SLOTS: inline void emitResultsReady(const QHostInfo &info) { if (slotObj) { - // we used to have a context object, but it's already destroyed - if (withContextObject && !receiver) - return; - QHostInfo copy = info; - void *args[2] = { 0, reinterpret_cast<void *>(©) }; - slotObj->call(const_cast<QObject*>(receiver.data()), args); + // we either didn't have a context object, or it's still alive + if (!withContextObject || receiver) { + QHostInfo copy = info; + void *args[2] = { 0, reinterpret_cast<void *>(©) }; + slotObj->call(const_cast<QObject*>(receiver.data()), args); + } slotObj->destroyIfLastRef(); } else { emit resultsReady(info); |