From cbee333815ef601f863d481b7b8da9e2805331c4 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Wed, 5 Jun 2013 07:43:10 +0300 Subject: [PATCH] core: Fix another memory leak when removing profiles If one place inserts to req->profiles_removed with g_strdup then all places must do it, and if all places do it then g_free must be used when removing from it. --- src/device.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/device.c b/src/device.c index e30af0a16..3c44a773e 100644 --- a/src/device.c +++ b/src/device.c @@ -440,7 +440,7 @@ static void browse_request_free(struct browse_req *req) if (req->device) btd_device_unref(req->device); g_slist_free_full(req->profiles_added, g_free); - g_slist_free(req->profiles_removed); + g_slist_free_full(req->profiles_removed, g_free); if (req->records) sdp_list_free(req->records, (sdp_free_func_t) sdp_record_free); @@ -2772,9 +2772,12 @@ static void update_bredr_services(struct browse_req *req, sdp_list_t *recs) g_slist_append(req->profiles_added, profile_uuid); else { + l = g_slist_find_custom(req->profiles_removed, + profile_uuid, + (GCompareFunc) strcmp); + g_free(l->data); req->profiles_removed = - g_slist_remove(req->profiles_removed, - l->data); + g_slist_delete_link(req->profiles_removed, l); g_free(profile_uuid); } @@ -2991,7 +2994,7 @@ static void init_browse(struct browse_req *req, gboolean reverse) for (l = req->device->uuids; l; l = l->next) req->profiles_removed = g_slist_append(req->profiles_removed, - l->data); + g_strdup(l->data)); } static void store_services(struct btd_device *device) -- 2.11.0