From e63f2ba1081e06b688062a78331367bc7c48833d Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Mon, 30 Nov 2015 17:45:09 +0100 Subject: [PATCH] Fix some memory leaks. --- coreapi/callbacks.c | 5 ++++- coreapi/friendlist.c | 6 ++++++ gtk/utils.c | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/coreapi/callbacks.c b/coreapi/callbacks.c index 1046a308c..d1e87473a 100644 --- a/coreapi/callbacks.c +++ b/coreapi/callbacks.c @@ -1309,7 +1309,10 @@ static void notify(SalOp *op, SalSubscribeStatus st, const char *eventname, SalB } { LinphoneContent *ct=linphone_content_from_sal_body_handler(body_handler); - if (ct) linphone_core_notify_notify_received(lc,lev,eventname,ct); + if (ct) { + linphone_core_notify_notify_received(lc,lev,eventname,ct); + linphone_content_unref(ct); + } } if (st!=SalSubscribeNone){ linphone_event_set_state(lev,linphone_subscription_state_from_sal(st)); diff --git a/coreapi/friendlist.c b/coreapi/friendlist.c index 97636341e..1c4178aba 100644 --- a/coreapi/friendlist.c +++ b/coreapi/friendlist.c @@ -68,6 +68,7 @@ static char * create_resource_list_xml(const LinphoneFriendList *list) { /* Close the "entry" element. */ err = xmlTextWriterEndElement(writer); } + if (uri) ms_free(uri); } if (err >= 0) { /* Close the "list" element. */ @@ -116,6 +117,7 @@ static void linphone_friend_list_parse_multipart_related_body(LinphoneFriendList goto end; } version = atoi(version_str); + linphone_free_xml_text_content(version_str); if (version < list->expected_notification_version) { ms_warning("rlmi+xml: Discarding received notification with version %d because %d was expected", version, list->expected_notification_version); goto end; @@ -170,6 +172,7 @@ static void linphone_friend_list_parse_multipart_related_body(LinphoneFriendList linphone_core_notify_notify_presence_received(list->lc, friend); } } + linphone_content_unref(presence_part); } } if (cid != NULL) linphone_free_xml_text_content(cid); @@ -379,6 +382,7 @@ void linphone_friend_list_update_subscriptions(LinphoneFriendList *list, Linphon linphone_content_set_subtype(content, "resource-lists+xml"); linphone_content_set_string_buffer(content, xml_content); linphone_event_send_subscribe(event, content); + linphone_content_unref(content); } if (address != NULL) linphone_address_unref(address); if (xml_content != NULL) ms_free(xml_content); @@ -427,9 +431,11 @@ void linphone_friend_list_notify_presence_received(LinphoneFriendList *list, Lin subtype = linphone_content_get_subtype(first_part); if ((strcmp(type, "application") != 0) || (strcmp(subtype, "rlmi+xml") != 0)) { ms_warning("multipart presence notified but first part is not 'application/rlmi+xml'"); + linphone_content_unref(first_part); return; } linphone_friend_list_parse_multipart_related_body(list, body, linphone_content_get_string_buffer(first_part)); + linphone_content_unref(first_part); } } diff --git a/gtk/utils.c b/gtk/utils.c index 0d0ae64d0..943eed62b 100644 --- a/gtk/utils.c +++ b/gtk/utils.c @@ -118,6 +118,7 @@ bool_t linphone_gtk_is_friend(LinphoneCore *lc, const char *contact) { char *uri = linphone_address_as_string_uri_only(addr); LinphoneFriend *lf = linphone_core_get_friend_by_address(lc, uri); linphone_address_destroy(addr); + if (uri) ms_free(uri); if (lf) return TRUE; } return FALSE;