From: Martin Mares Date: Thu, 25 Dec 2014 12:16:30 +0000 (+0100) Subject: Pulse: Don't crash when removing an unknown client X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=5b9beac5726dc1220e271056a19347e0249237f7;p=ursary.git Pulse: Don't crash when removing an unknown client --- 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 ***/