Bug 381583 - potential crash in KDirWatch::~KDirWatch()
Summary: potential crash in KDirWatch::~KDirWatch()
Status: RESOLVED FIXED
Alias: None
Product: frameworks-kcoreaddons
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: unspecified
Platform: Compiled Sources All
: NOR normal
Target Milestone: ---
Assignee: Michael Pyne
URL:
Keywords:
: 368278 (view as bug list)
Depends on:
Blocks:
 
Reported: 2017-06-23 15:26 UTC by RJVB
Modified: 2017-08-06 21:13 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.37


Attachments
check the d_ptr before using it (388 bytes, text/plain)
2017-06-23 15:26 UTC, RJVB
Details

Note You need to log in before you can comment on or make changes to this bug.
Description RJVB 2017-06-23 15:26:18 UTC
Created attachment 106264 [details]
check the d_ptr before using it

The KDirWatch dtor assumes that it always has a KDirWatchPrivate instance, an assumption not shared by (most of) the other class methods. I stumbled upon this during what could be called foolproofing (testing plasmoid with plasmawindowed outside of a running Plasma5 environment).
Comment 1 Michael Pyne 2017-06-24 02:11:02 UTC
I think this makes sense.  Seems to me that the current code could lead to a crash if the KDirWatch qPostRoutine were called (this nullifies the d-ptr) followed by the KDirWatch itself being destructed.  David, any thoughts on whether there's a better way to handle this?
Comment 2 David Faure 2017-07-08 13:40:27 UTC
This patch looks fine, please push it.
Comment 3 Michael Pyne 2017-07-08 19:01:15 UTC
Git commit b8cb28bcd0709a0ff49ac1ae40c0f44e7ea36f33 by Michael Pyne, on behalf of René J.V. Bertin.
Committed on 08/07/2017 at 19:00.
Pushed by mpyne into branch 'master'.

kdirwatch: Avoid potential crash if d-ptr destroyed before KDirWatch.

Found in a code review and patch proposed by René, although we've not
actually gone so far as to create a test case that forces a crash.

Committed by mpyne to get the bug closed out.
FIXED-IN:5.37

M  +1    -1    src/lib/io/kdirwatch.cpp

https://commits.kde.org/kcoreaddons/b8cb28bcd0709a0ff49ac1ae40c0f44e7ea36f33
Comment 4 Michael Pyne 2017-08-06 21:13:31 UTC
*** Bug 368278 has been marked as a duplicate of this bug. ***