D29616: Fix memory errors caused by using dangling pointers to SensorClients in SensorAgent

Arjen Hiemstra noreply at phabricator.kde.org
Mon May 11 15:20:04 BST 2020


ahiemstra requested changes to this revision.
ahiemstra added inline comments.
This revision now requires changes to proceed.

INLINE COMMENTS

> jpalecek wrote in SensorBrowser.cpp:53
> No, it only deletes the HostInfo structure. See the source <https://phabricator.kde.org/source/ksysguard/browse/master/gui/SensorBrowser.h$187>. It doesn't disconnect anything. Nor does deleting `this`, as the Agent holds the client as a bare pointer, it can't know that it ceased to exist. It isn't even a `QPointer` (probably bc. `SensorClient` isn't a `QObject`).

I agree with Anthony though, if you delete a hostInfo it _should_ remove its connection. So it's better to move this code into a destructor for HostInfo.

> ksysguard.cpp:153
> +{
> +  if (KSGRD::SensorMgr) KSGRD::SensorMgr->disconnectClient(this);
> +}

Coding style: Single line ifs still need braces and should not be on a single line.

REPOSITORY
  R106 KSysguard

REVISION DETAIL
  https://phabricator.kde.org/D29616

To: jpalecek, davidedmundson, ahiemstra
Cc: anthonyfieroni, plasma-devel, Orage, LeGast00n, The-Feren-OS-Dev, cblack, jraleigh, zachus, fbampaloukas, ragreen, ZrenBot, ngraham, himcesjf, lesliezhai, ali-mohamed, jensreuterberg, abetts, sebas, apol, ahiemstra, mart
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/plasma-devel/attachments/20200511/c556c160/attachment-0001.htm>


More information about the Plasma-devel mailing list