summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikel Astiz <mikel.astiz@bmw-carit.de>2012-10-17 12:07:09 +0200
committerJohan Hedberg <johan.hedberg@intel.com>2012-10-17 13:15:45 +0300
commit340cdeb404a42806780124039b98676f6e6cc808 (patch)
treee7b3558327fa2e57429f03e23d701c250d383a98
parentfd16f2cc64554bc4e9b9b04c5267c71223a04cff (diff)
device: Fix modifying list while iterating
A list should not be modified while iterating on it, and in this case the solution is trivial: the code is just trying to free the whole list with a previous call to profile->device_remove() per list item.
-rw-r--r--src/device.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/device.c b/src/device.c
index f48faba1..bb0f8904 100644
--- a/src/device.c
+++ b/src/device.c
@@ -872,8 +872,6 @@ static void profile_remove(struct btd_profile *profile,
struct btd_device *device)
{
profile->device_remove(profile, device);
-
- device->profiles = g_slist_remove(device->profiles, profile);
}
static gboolean do_disconnect(gpointer user_data)
@@ -899,6 +897,8 @@ int device_block(struct btd_device *device, gboolean update_only)
do_disconnect(device);
g_slist_foreach(device->profiles, (GFunc) profile_remove, device);
+ g_slist_free(device->profiles);
+ device->profiles = NULL;
if (!update_only)
err = btd_adapter_block_address(device->adapter,