]> mj.ucw.cz Git - ursary.git/commitdiff
Pulse: Don't crash when removing an unknown client
authorMartin Mares <mj@ucw.cz>
Thu, 25 Dec 2014 12:16:30 +0000 (13:16 +0100)
committerMartin Mares <mj@ucw.cz>
Thu, 25 Dec 2014 12:16:30 +0000 (13:16 +0100)
pulse.c

diff --git a/pulse.c b/pulse.c
index 302f6a4156bfd0afa27a39dcef1bb96d7570ae42..d6a26b613c28bf488b433c6f465cd44bf7f7684a 100644 (file)
--- 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 ***/