From bd0061f227b525cf58f598ddf2c279f7b42976c3 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Thu, 24 Sep 2015 22:06:30 +0200 Subject: [PATCH] fix memory leak and add new test to check that linphone_core_destroy() sends BYE for unterminated calls. --- coreapi/linphonecore.c | 2 ++ tester/call_tester.c | 23 +++++++++++++++++++++++ tester/common/bc_tester_utils.c | 1 + 3 files changed, 26 insertions(+) diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index e25e171f3..5871425d1 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -1460,6 +1460,7 @@ static void linphone_core_register_static_payloads(LinphoneCore *lc){ static void linphone_core_free_payload_types(LinphoneCore *lc){ ms_list_free_with_data(lc->default_audio_codecs, (void (*)(void*))payload_type_destroy); ms_list_free_with_data(lc->default_video_codecs, (void (*)(void*))payload_type_destroy); + ms_list_free_with_data(lc->default_text_codecs, (void (*)(void*))payload_type_destroy); } void linphone_core_set_state(LinphoneCore *lc, LinphoneGlobalState gstate, const char *message){ @@ -6257,6 +6258,7 @@ static void codecs_config_uninit(LinphoneCore *lc) _linphone_core_codec_config_write(lc); ms_list_free_with_data(lc->codecs_conf.audio_codecs, (void (*)(void*))payload_type_destroy); ms_list_free_with_data(lc->codecs_conf.video_codecs, (void (*)(void*))payload_type_destroy); + ms_list_free_with_data(lc->codecs_conf.text_codecs, (void (*)(void*))payload_type_destroy); } void ui_config_uninit(LinphoneCore* lc) diff --git a/tester/call_tester.c b/tester/call_tester.c index 411021556..a43968e3b 100644 --- a/tester/call_tester.c +++ b/tester/call_tester.c @@ -411,6 +411,28 @@ static void simple_call() { simple_call_base(FALSE); } +static void automatic_call_termination() { + LinphoneCoreManager* marie; + LinphoneCoreManager* pauline; + + marie = linphone_core_manager_new( "marie_rc"); + pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); + + + if (!BC_ASSERT_TRUE(call(marie,pauline))) goto end; + + liblinphone_tester_check_rtcp(marie,pauline); + + linphone_core_destroy(pauline->lc); + pauline->lc = NULL; + /*marie shall receive the BYE*/ + BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallEnd, 1)); + BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallReleased, 1)); +end: + linphone_core_manager_destroy(pauline); + linphone_core_manager_destroy(marie); +} + static void call_with_timeouted_bye(void) { LinphoneCoreManager* marie; LinphoneCoreManager* pauline; @@ -4950,6 +4972,7 @@ test_t call_tests[] = { { "Cancelled ringing call", cancelled_ringing_call }, { "Call busy when calling self", call_busy_when_calling_self}, { "Simple call", simple_call }, + { "Call terminated automatically by linphone_core_destroy", automatic_call_termination }, { "Call with http proxy", call_with_http_proxy }, { "Call with timeouted bye", call_with_timeouted_bye }, { "Direct call over IPv6", direct_call_over_ipv6}, diff --git a/tester/common/bc_tester_utils.c b/tester/common/bc_tester_utils.c index 8342a25a1..3b9ddbd4a 100644 --- a/tester/common/bc_tester_utils.c +++ b/tester/common/bc_tester_utils.c @@ -362,6 +362,7 @@ static void detect_res_prefix(const char* prog) { #endif if (prog != NULL) { + if (progpath) free(progpath); progpath = strdup(prog); if (strchr(prog, '/') != NULL) { progpath[strrchr(prog, '/') - prog + 1] = '\0';