]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Fixes memory leak in KItemListViewAccessible
authorDavid Hallas <david@davidhallas.dk>
Wed, 18 Jul 2018 21:20:18 +0000 (23:20 +0200)
committerElvis Angelaccio <elvis.angelaccio@kde.org>
Wed, 18 Jul 2018 21:20:19 +0000 (23:20 +0200)
Summary: The KItemListViewAccessible class has a list of QAccessibleInterface pointers in a member variable m_cells. The problem is that when new entries are created, the newly allocated pointer is not stored in the list, only a nullptr is store, this renders the cleanup code in the destructor useless. This patch simply stores the pointer in the list, causing the destructor to correctly free the memory.

Test Plan: I found this issue using address sanitizer. Simply building Dolphin with -fsanitize=address and opening a window caused the memory leak.

Reviewers: #dolphin, jtamate, elvisangelaccio

Reviewed By: #dolphin, jtamate, elvisangelaccio

Subscribers: elvisangelaccio, kfm-devel

Tags: #dolphin

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

src/kitemviews/kitemlistviewaccessible.cpp

index 69c126f6d6cf08fc7bfdd18d3bd7018293097bb1..4d1b28b9fd35337f8e6729333f93a2258d592877 100644 (file)
@@ -78,6 +78,7 @@ QAccessibleInterface* KItemListViewAccessible::cell(int index) const
     QAccessibleInterface* child = m_cells.at(index);
     if (!child) {
         child = new KItemListAccessibleCell(view(), index);
+        m_cells.insert(index, child);
         QAccessible::registerAccessibleInterface(child);
     }
     return child;