From b0566c457e956e03ae5ff3fe4ae15a9176b0ae24 Mon Sep 17 00:00:00 2001 From: Claudio Takahasi Date: Mon, 10 Mar 2008 20:48:10 +0000 Subject: bt_list2string: fixed memory leak --- common/glib-helper.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'common/glib-helper.c') diff --git a/common/glib-helper.c b/common/glib-helper.c index bed506c3..cb8f35c4 100644 --- a/common/glib-helper.c +++ b/common/glib-helper.c @@ -261,7 +261,7 @@ char *bt_uuid2string(uuid_t *uuid) gchar *bt_list2string(GSList *list) { GSList *l; - gchar *str = NULL; + gchar *str, *tmp; if (!list) return NULL; @@ -269,8 +269,11 @@ gchar *bt_list2string(GSList *list) str = g_strdup((const gchar *) list->data); /* FIXME: eglib doesn't support g_strconcat */ - for (l = list->next; l; l = l->next) - str = g_strconcat(str, " " , (const gchar *) l->data, NULL); + for (l = list->next; l; l = l->next) { + tmp = g_strconcat(str, " " , (const gchar *) l->data, NULL); + g_free(str); + str = tmp; + } return str; } -- cgit