tools/mpris-proxy: unregister object path if player registration fails
authorHaochen Tong <i@hexchain.org>
Sun, 25 Sep 2022 16:31:39 +0000 (00:31 +0800)
committerAyush Garg <ayush.garg@samsung.com>
Mon, 15 May 2023 09:25:55 +0000 (14:55 +0530)
The `owner' string, passed as user data, is freed if the player fails
registration, but the object path still exists. Upon program exiting,
the lingering path will be enumerated and the attached user data will be
freed again.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
tools/mpris-proxy.c

index 9f868e0..5edce43 100755 (executable)
@@ -479,6 +479,7 @@ static void add_player(DBusConnection *conn, const char *name,
        reply = dbus_connection_send_with_reply_and_block(sys, msg, -1, &err);
        if (!reply) {
                fprintf(stderr, "Can't register player\n");
+               dbus_connection_unregister_object_path(sys, path);
                free(owner);
                if (dbus_error_is_set(&err)) {
                        fprintf(stderr, "%s\n", err.message);