KDirWatch: fix memory leak on destruction.
authorDavid Faure <faure@kde.org>
Sun, 5 Feb 2017 10:49:07 +0000 (11:49 +0100)
committerMaximiliano Curia <maxy@debian.org>
Fri, 31 Mar 2017 13:53:53 +0000 (14:53 +0100)
commitee29f33017da252f3a6d3acd77ef107445c681c7
tree9efae6e498cdbf01c9f8b6e1d772db86419a8270
parentebdf955e48db51b3cc2fa6279c5cfb5094112602
KDirWatch: fix memory leak on destruction.

Summary:
The Entry class owns the Client instances, so it should delete the
remaining instances in its destructor, for the case where they haven't
been removed one by one. The line of code removeEntries(nullptr) was
probably means to remove them one by one, but it was a no-op (the code
for that method doesn't expect nullptr as argument) and it would be
slow anyway. We don't need to call inotify_remove for every path,
when we're just cleaning up in a global static after qApp destruction.

Detected by a clang-sanitizer build on http://ci-logs.kde.flaska.net
and reproduced locally with valgrind.

Test Plan:
./kdirwatch_*_unittest now passes in valgrind without memory
leaks being reported

Reviewers: aacid, mpyne

Reviewed By: aacid, mpyne

Subscribers: markg, #frameworks

Tags: #frameworks

Differential Revision: https://phabricator.kde.org/D4439

Gbp-Pq: Name KDirWatch-fix-memory-leak-on-destruction.patch
src/lib/io/kdirwatch.cpp
src/lib/io/kdirwatch_p.h