Skip to content

dbus: fix memory leak on tracklist events

After MR !3189 (merged) 1, the leak was fixed when closing the interface before the events are processed, but not when the events were being processed and the ownership moved to the dbus thread.

When a second tracklist (append or remove) event was queued to the dbus thread, it detected that an existing event was already there and discarded the event without destroying it, despite the ownership being transferred.

It is necessary to check whether the event was transferred or not and release it if not, which will be done in a following commit, but the tracklist events are gathered by the event processing code and event type duplicates don't have the same information and shouldn't be discarded first, which solves the following root leak:

==81939==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 40 byte(s) in 1 object(s) allocated from:
    #0 0x7fd01ced85cf in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:69
    #1 0x7fd00d6a3129 in tracklist_append_event_create ../../modules/control/dbus/dbus_tracklist.c:41
    #2 0x7fd00d6b1f98 in playlist_on_items_added ../../modules/control/dbus/dbus.c:1063
    #3 0x7fd01c03e071 in vlc_playlist_ItemsInserted ../../src/playlist/content.c:76
    #4 0x7fd01c045b3e in vlc_playlist_Expand ../../src/playlist/content.c:382
    #5 0x7fd01c0537e8 in vlc_playlist_ExpandItem ../../src/playlist/preparse.c:59
    #6 0x7fd01c053942 in vlc_playlist_ExpandItemFromNode ../../src/playlist/preparse.c:76
    #7 0x7fd01c05397f in on_subtree_added ../../src/playlist/preparse.c:87
    #8 0x7fd01c070088 in OnParserSubtreeAdded ../../src/preparser/preparser.c:171
    #9 0x7fd01c08848b in input_item_parser_InputEvent ../../src/input/item.c:1402

Refs #27780 (closed) Fixes #28307 (closed)

  1. !3189 (merged)

Merge request reports