From 83cd09ba2f30ff3ac2e4659892ee083f1f97bdad Mon Sep 17 00:00:00 2001 From: Benjamin Berg Date: Fri, 13 Nov 2020 14:00:48 +0100 Subject: [PATCH] device: Unwatch names when removing them If a device is unplugged/destroyed while a client is using it, then we would still end up watching the name. The vanish notification will then access the destroyed FprintDevice object. Fix this by unwatching the bus name when removing the client entry from the dictionary. --- src/device.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/device.c b/src/device.c index 75d05fc..a818306 100644 --- a/src/device.c +++ b/src/device.c @@ -305,6 +305,11 @@ static void fprint_device_class_init(FprintDeviceClass *klass) quark_auth_user = g_quark_from_static_string ("authorized-user"); } +static void _unwatch_name (gpointer id) +{ + g_bus_unwatch_name (GPOINTER_TO_INT (id)); +} + static void fprint_device_init(FprintDevice *device) { FprintDevicePrivate *priv = fprint_device_get_instance_private(device); @@ -315,7 +320,7 @@ static void fprint_device_init(FprintDevice *device) priv->clients = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, - NULL); + _unwatch_name); g_signal_connect (device, "g-authorize-method", G_CALLBACK (action_authorization_handler),