From b41791221213b0c5b1d66ed52462b5960e070ea5 Mon Sep 17 00:00:00 2001 From: Santiago Carot-Nemesio Date: Tue, 31 Jan 2012 16:59:05 +0100 Subject: [PATCH] device: Fix segmentation fault removing devices There is an unbalanced control regarding to the GATT channel and its attachid, we have to to update the attach id value by setting it to zero whenever we detach a GATT channel. --- src/device.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/device.c b/src/device.c index b2c83797e..93e454e8a 100644 --- a/src/device.c +++ b/src/device.c @@ -1739,6 +1739,7 @@ static void attrib_disconnected(gpointer user_data) attrib_channel_detach(device->attrib, device->attachid); g_attrib_unref(device->attrib); device->attrib = NULL; + device->attachid = 0; if (device->auto_connect == FALSE) return; @@ -1786,6 +1787,7 @@ static void primary_cb(GSList *services, guint8 status, gpointer user_data) if (device->attios == NULL && device->attios_offline == NULL) { attrib_channel_detach(device->attrib, device->attachid); + device->attachid = 0; g_attrib_unref(device->attrib); device->attrib = NULL; } else @@ -2858,7 +2860,7 @@ gboolean btd_device_remove_attio_callback(struct btd_device *device, guint id) if (device->attios != NULL || device->attios_offline != NULL) return TRUE; - if (device->attachid) { + if (device->attachid > 0) { attrib_channel_detach(device->attrib, device->attachid); device->attachid = 0; } -- 2.47.3