gio: fix race condition in GDBusObjectManagerClient

priv->map_object_path_to_object_proxy must be protected to avoid
concurrent access by multiple threads. Move the hash table insertion
into the critical section.

https://bugzilla.gnome.org/show_bug.cgi?id=788368
This commit is contained in:
Beniamino Galvani 2017-09-30 11:26:29 +02:00 committed by Philip Withnall
parent 1fb56be6ab
commit aeecd81dd1

View File

@ -1542,6 +1542,13 @@ add_interfaces (GDBusObjectManagerClient *manager,
g_variant_unref (properties);
}
if (added)
{
g_hash_table_insert (manager->priv->map_object_path_to_object_proxy,
g_strdup (object_path),
op);
}
g_mutex_unlock (&manager->priv->lock);
/* now that we don't hold the lock any more, emit signals */
@ -1555,12 +1562,8 @@ add_interfaces (GDBusObjectManagerClient *manager,
g_list_free (interface_added_signals);
if (added)
{
g_hash_table_insert (manager->priv->map_object_path_to_object_proxy,
g_strdup (object_path),
op);
g_signal_emit_by_name (manager, "object-added", op);
}
g_signal_emit_by_name (manager, "object-added", op);
g_object_unref (manager);
g_object_unref (op);
}