module-stream-restore: check if dbus entry exists in dbus_entries map before creating it
authorIgor V. Kovalenko <igor.v.kovalenko@gmail.com>
Tue, 13 Oct 2020 06:36:50 +0000 (09:36 +0300)
committerArun Raghavan <arun@arunraghavan.net>
Tue, 13 Oct 2020 10:35:44 +0000 (10:35 +0000)
If write_entry fails to store new entry in database, next time we can try creating new entry again.
With DBUS enabled this will create another dbus entry for same name leading to crash inserting duplicate into dbus_entries map.

Fix this by checking if dbus entry exists in dbus_entries map before creating it.

Fixes: #974
src/modules/module-stream-restore.c

index d29f079a818fe9f467a5565a01e48844c583ec48..7144a664b48988a025bf27bad15d8ee1383f4f0a 100644 (file)
@@ -1448,13 +1448,11 @@ static void subscribe_callback(pa_core *c, pa_subscription_event_type_t t, uint3
     }
 
 #ifdef HAVE_DBUS
-    if (created_new_entry) {
+    if (!(de = pa_hashmap_get(u->dbus_entries, name))) {
         de = dbus_entry_new(u, name);
         pa_assert_se(pa_hashmap_put(u->dbus_entries, de->entry_name, de) == 0);
         send_new_entry_signal(de);
     } else {
-        pa_assert_se(de = pa_hashmap_get(u->dbus_entries, name));
-
         if (device_updated)
             send_device_updated_signal(de, entry);
         if (volume_updated)