From 5b9beac5726dc1220e271056a19347e0249237f7 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Thu, 25 Dec 2014 13:16:30 +0100 Subject: [PATCH] Pulse: Don't crash when removing an unknown client --- pulse.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/pulse.c b/pulse.c index 302f6a4..d6a26b6 100644 --- a/pulse.c +++ b/pulse.c @@ -290,6 +290,7 @@ void pulse_sink_set_mute(int idx, bool mute) #define HASH_PREFIX(x) pulse_client_##x #define HASH_KEY_ATOMIC idx #define HASH_WANT_CLEANUP +#define HASH_WANT_FIND #define HASH_WANT_LOOKUP #define HASH_WANT_REMOVE #define HASH_ZERO_FILL @@ -326,15 +327,18 @@ static void pulse_client_cb(pa_context *ctx UNUSED, const pa_client_info *i, int static void pulse_client_gone(int idx) { DBG("Pulse: REMOVE CLIENT #%d", idx); - struct pulse_client *c = pulse_client_lookup(idx); - clist_remove(&c->n); - pulse_client_remove(c); - schedule_update(); + struct pulse_client *c = pulse_client_find(idx); + if (c) + { + clist_remove(&c->n); + pulse_client_remove(c); + schedule_update(); + } } struct pulse_client *pulse_client_by_idx(int idx) { - return pulse_client_lookup(idx); + return pulse_client_find(idx); } /*** Events ***/ -- 2.39.2