summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@nokia.com>2008-10-10 13:49:44 +0200
committerJohan Hedberg <johan.hedberg@nokia.com>2008-10-10 13:49:44 +0200
commit0e073403c77dd0906cd89dbd2d2b6707f4493188 (patch)
tree570c81647631a5faf5acbd733efb462b526387ba
parent9ffbfb5e9db21cba81ac8af6d2c170882e00b17c (diff)
Fix uuid list allocation and freeing bug exposed by previous mem leak fix
-rw-r--r--src/adapter.c1
-rw-r--r--src/device.c10
2 files changed, 5 insertions, 6 deletions
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);
}