From 23e605cc5b71f68d6c9e6168053226d027ea46d4 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Tue, 30 Jul 2019 16:42:44 +0200 Subject: 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 --- src/network/kernel/qhostinfo_p.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src') 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(©) }; - slotObj->call(const_cast(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(©) }; + slotObj->call(const_cast(receiver.data()), args); + } slotObj->destroyIfLastRef(); } else { emit resultsReady(info); -- cgit v1.2.3