From f7abf57253968713659f765e0e4e85f13d6bcee1 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Wed, 9 Mar 2016 18:14:02 +0100 Subject: [PATCH] Fix some memory leaks. --- coreapi/event.c | 4 ++-- coreapi/friendlist.c | 1 - coreapi/proxy.c | 1 + tester/presence_tester.c | 5 +++++ 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/coreapi/event.c b/coreapi/event.c index 8f00111d8..36579d0d2 100644 --- a/coreapi/event.c +++ b/coreapi/event.c @@ -358,8 +358,8 @@ LinphoneEvent *linphone_event_ref(LinphoneEvent *lev){ } static void linphone_event_destroy(LinphoneEvent *lev){ - if (lev->op) - sal_op_release(lev->op); + if (lev->op) sal_op_release(lev->op); + if (lev->send_custom_headers) sal_custom_header_free(lev->send_custom_headers); ms_free(lev->name); } diff --git a/coreapi/friendlist.c b/coreapi/friendlist.c index f2edbff46..dd549be87 100644 --- a/coreapi/friendlist.c +++ b/coreapi/friendlist.c @@ -623,7 +623,6 @@ void linphone_friend_list_update_subscriptions(LinphoneFriendList *list, Linphon linphone_event_unref(list->event); } list->event = linphone_core_create_subscribe(list->lc, address, "presence", expires); - linphone_event_ref(list->event); linphone_event_set_internal(list->event, TRUE); linphone_event_add_custom_header(list->event, "Require", "recipient-list-subscribe"); linphone_event_add_custom_header(list->event, "Supported", "eventlist"); diff --git a/coreapi/proxy.c b/coreapi/proxy.c index 645d4eb89..6743f93c1 100644 --- a/coreapi/proxy.c +++ b/coreapi/proxy.c @@ -1111,6 +1111,7 @@ int linphone_proxy_config_send_publish(LinphoneProxyConfig *proxy, LinphonePrese linphone_content_set_subtype(content,"pidf+xml"); err = linphone_event_send_publish(proxy->long_term_event, content); linphone_content_unref(content); + ms_free(presence_body); }else proxy->send_publish=TRUE; /*otherwise do not send publish if registration is in progress, this will be done later*/ return err; } diff --git a/tester/presence_tester.c b/tester/presence_tester.c index 0b7e4a546..ce4c131e9 100644 --- a/tester/presence_tester.c +++ b/tester/presence_tester.c @@ -728,10 +728,13 @@ static void test_presence_list_base(bool_t enable_compression) { linphone_friend_list_set_rls_uri(lfl, rls_uri); lf = linphone_core_create_friend_with_address(laure->lc, marie_identity); linphone_friend_list_add_friend(lfl, lf); + linphone_friend_unref(lf); lf = linphone_core_create_friend_with_address(laure->lc, pauline_identity); linphone_friend_list_add_friend(lfl, lf); + linphone_friend_unref(lf); lf = linphone_core_create_friend_with_address(laure->lc, "sip:michelle@sip.inexistentdomain.com"); linphone_friend_list_add_friend(lfl, lf); + linphone_friend_unref(lf); linphone_core_remove_friend_list(laure->lc, linphone_core_get_default_friend_list(laure->lc)); linphone_core_add_friend_list(laure->lc, lfl); linphone_friend_list_unref(lfl); @@ -761,6 +764,7 @@ static void test_presence_list_base(bool_t enable_compression) { linphone_friend_list_set_rls_uri(lfl, rls_uri); lf = linphone_core_create_friend_with_address(marie->lc, laure_identity); linphone_friend_list_add_friend(lfl, lf); + linphone_friend_unref(lf); linphone_core_remove_friend_list(marie->lc, linphone_core_get_default_friend_list(marie->lc)); linphone_core_add_friend_list(marie->lc, lfl); linphone_friend_list_unref(lfl); @@ -778,6 +782,7 @@ static void test_presence_list_base(bool_t enable_compression) { linphone_friend_list_set_rls_uri(lfl, rls_uri); lf = linphone_core_create_friend_with_address(pauline->lc, marie_identity); linphone_friend_list_add_friend(lfl, lf); + linphone_friend_unref(lf); linphone_core_remove_friend_list(pauline->lc, linphone_core_get_default_friend_list(pauline->lc)); linphone_core_add_friend_list(pauline->lc, lfl); linphone_friend_list_unref(lfl);