[PATCH] Fix memory leak in adapter_service_ins_rem()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



---
 src/adapter.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/adapter.c b/src/adapter.c
index 5118306..407522f 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -980,7 +980,7 @@ static void adapter_service_ins_rem(const bdaddr_t *bdaddr, void *rec,
 							gboolean insert)
 {
 	struct btd_adapter *adapter;
-	GSList *adapters;
+	GSList *l, *adapters;
 
 	adapters = NULL;
 
@@ -995,8 +995,8 @@ static void adapter_service_ins_rem(const bdaddr_t *bdaddr, void *rec,
 		/* Emit D-Bus msg to all adapters */
 		adapters = manager_get_adapters();
 
-	for (; adapters; adapters = adapters->next) {
-		adapter = adapters->data;
+	for (l = adapters; l; l = l->next) {
+		adapter = l->data;
 
 		if (insert == TRUE)
 			adapter->services = sdp_list_insert_sorted(
@@ -1008,6 +1008,9 @@ static void adapter_service_ins_rem(const bdaddr_t *bdaddr, void *rec,
 
 		adapter_emit_uuids_updated(adapter);
 	}
+
+	if (bacmp(bdaddr, BDADDR_ANY) != 0)
+		g_slist_free(adapters);
 }
 
 void adapter_service_insert(const bdaddr_t *bdaddr, void *rec)
-- 
1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux