From c9621b011a3c5cd300c62c661322bfd32cca5f51 Mon Sep 17 00:00:00 2001 From: Radoslaw Jablonski Date: Thu, 3 Feb 2011 11:43:22 +0200 Subject: [PATCH] obexd: Move freeing contacts data to phonebook_req_finalize Previously data used for generating vcards was freed only in gen_vcards body. This may result a memory leak, if fetching data from tracker was cancelled in the middle of process and gen_vcards wasn't called. Phonebook_req_finalize is better place for this kind of cleanup. --- obexd/plugins/phonebook-tracker.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/obexd/plugins/phonebook-tracker.c b/obexd/plugins/phonebook-tracker.c index ceaef810f..af660c17e 100644 --- a/obexd/plugins/phonebook-tracker.c +++ b/obexd/plugins/phonebook-tracker.c @@ -1324,10 +1324,6 @@ static GString *gen_vcards(GSList *contacts, struct contact_data *c_data = l->data; phonebook_add_contact(vcards, c_data->contact, params->filter, params->format); - - g_free(c_data->id); - phonebook_contact_free(c_data->contact); - g_free(c_data); } return vcards; @@ -1787,6 +1783,7 @@ done: void phonebook_req_finalize(void *request) { struct phonebook_data *data = request; + GSList *l; DBG(""); @@ -1798,6 +1795,15 @@ void phonebook_req_finalize(void *request) dbus_pending_call_unref(data->call); + /* freeing list of contacts used for generating vcards */ + for (l = data->contacts; l; l = l->next) { + struct contact_data *c_data = l->data; + + g_free(c_data->id); + phonebook_contact_free(c_data->contact); + g_free(c_data); + } + g_slist_free(data->contacts); g_free(data); } -- 2.47.3