From 0e073403c77dd0906cd89dbd2d2b6707f4493188 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Fri, 10 Oct 2008 13:49:44 +0200 Subject: Fix uuid list allocation and freeing bug exposed by previous mem leak fix --- src/adapter.c | 1 + src/device.c | 10 ++++------ 2 files changed, 5 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/adapter.c b/src/adapter.c index f983069e..c2304e99 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -2295,6 +2295,7 @@ static void create_stored_device_from_profiles(char *key, char *value, device_probe_drivers(device, uuids); + g_slist_foreach(uuids, (GFunc) g_free, NULL); g_slist_free(uuids); } diff --git a/src/device.c b/src/device.c index a5a9d523..7294d3ca 100644 --- a/src/device.c +++ b/src/device.c @@ -668,7 +668,8 @@ void device_probe_drivers(struct btd_device *device, GSList *uuids) continue; device->uuids = g_slist_insert_sorted(device->uuids, - list->data, (GCompareFunc) strcasecmp); + g_strdup(list->data), + (GCompareFunc) strcasecmp); } if (device->tmp_records) { @@ -1349,17 +1350,14 @@ void btd_device_add_uuid(struct btd_device *device, const char *uuid) return; new_uuid = g_strdup(uuid); - - device->uuids = g_slist_append(device->uuids, new_uuid); - - store_profiles(device); - uuid_list = g_slist_append(NULL, new_uuid); device_probe_drivers(device, uuid_list); + g_free(new_uuid); g_slist_free(uuid_list); + store_profiles(device); services_changed(device); } -- cgit