From 28e6ee40b23e25d401c5736bbe6f907a8f3ffdf1 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Wed, 14 Oct 2015 14:21:41 +0200 Subject: [PATCH] fix crash when calling linphone_call_get_remote_params() when no incoming message is received yet. --- coreapi/linphonecall.c | 9 +++++++-- tester/call_tester.c | 7 +++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index 4c4609051..e850691ee 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -1783,8 +1783,8 @@ const LinphoneCallParams * linphone_call_get_remote_params(LinphoneCall *call){ if (call->op){ LinphoneCallParams *cp; SalMediaDescription *md; + const SalCustomHeader *ch; - md=sal_call_get_remote_media_description(call->op); if (md) { SalStreamDescription *sd; unsigned int i; @@ -1820,7 +1820,12 @@ const LinphoneCallParams * linphone_call_get_remote_params(LinphoneCall *call){ linphone_call_params_set_custom_sdp_media_attributes(call->remote_params, LinphoneStreamTypeVideo, md->streams[call->main_video_stream_index].custom_sdp_attributes); linphone_call_params_set_custom_sdp_media_attributes(call->remote_params, LinphoneStreamTypeText, md->streams[call->main_text_stream_index].custom_sdp_attributes); } - linphone_call_params_set_custom_headers(call->remote_params, sal_op_get_recv_custom_header(call->op)); + ch = sal_op_get_recv_custom_header(call->op); + if (ch){ + /*instanciate a remote_params only if a SIP message was received before (custom headers indicates this).*/ + if (call->remote_params == NULL) call->remote_params = linphone_call_params_new(); + linphone_call_params_set_custom_headers(call->remote_params, ch); + } return call->remote_params; } return NULL; diff --git a/tester/call_tester.c b/tester/call_tester.c index db6ee0bcf..6dc5b89c2 100644 --- a/tester/call_tester.c +++ b/tester/call_tester.c @@ -214,15 +214,18 @@ bool_t call_with_params2(LinphoneCoreManager* caller_mgr LinphoneCallParams *callee_params = callee_test_params->base; bool_t did_receive_call; LinphoneCall *callee_call=NULL; + LinphoneCall *caller_call=NULL; setup_sdp_handling(caller_test_params, caller_mgr); setup_sdp_handling(callee_test_params, callee_mgr); if (!caller_params){ - BC_ASSERT_PTR_NOT_NULL(linphone_core_invite_address(caller_mgr->lc,callee_mgr->identity)); + BC_ASSERT_PTR_NOT_NULL((caller_call=linphone_core_invite_address(caller_mgr->lc,callee_mgr->identity))); }else{ - BC_ASSERT_PTR_NOT_NULL(linphone_core_invite_address_with_params(caller_mgr->lc,callee_mgr->identity,caller_params)); + BC_ASSERT_PTR_NOT_NULL((caller_call=linphone_core_invite_address_with_params(caller_mgr->lc,callee_mgr->identity,caller_params))); } + + BC_ASSERT_PTR_NULL(linphone_call_get_remote_params(caller_call)); /*assert that remote params are NULL when no response is received yet*/ did_receive_call = wait_for(callee_mgr->lc ,caller_mgr->lc