From a2bd04f7318e9935805dba47d71c32e65aa0e4b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20=C5=A0imko?= Date: Sat, 10 Oct 2020 22:27:28 +0000 Subject: [PATCH] avrcp: Fix segfault when using headset controls This fixes a segmentation fault caused by controls trying to notify an unregistered player. When an unregistered player is replaced by another valid player from the list, the session is not referenced in the sessions list of the player and when this player is unregistered, its reference is not removed from the session. --- profiles/audio/avrcp.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c index ed436de3b..92477ae4d 100644 --- a/profiles/audio/avrcp.c +++ b/profiles/audio/avrcp.c @@ -4441,8 +4441,14 @@ void avrcp_unregister_player(struct avrcp_player *player) if (target == NULL) continue; - if (target->player == player) - target->player = g_slist_nth_data(server->players, 0); + if (target->player != player) + continue; + + target->player = g_slist_nth_data(server->players, 0); + if (target->player) + target->player->sessions = g_slist_append( + target->player->sessions, + session); } avrcp_player_event(player, -- 2.47.3