From 4a395bfb7280d1c8344e80f76876d2b9275c0fe5 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Thu, 11 Apr 2013 17:47:30 +0200 Subject: [PATCH] make sure terminate call does nothing if call in state LinphoneCallReleased or LinphoneCallEnd --- coreapi/linphonecore.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 9731d773e..bb257e60b 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -3269,14 +3269,26 @@ int linphone_core_terminate_call(LinphoneCore *lc, LinphoneCall *the_call) { call = the_call; } + switch (call->state) { + case LinphoneCallReleased: + case LinphoneCallEnd: + ms_warning("No need to terminate a call [%p] in sate [%s]",call,linphone_call_state_to_string(call->state)); + return -1; + case LinphoneCallIncomingReceived: + case LinphoneCallIncomingEarlyMedia: + return linphone_core_decline_call(lc,call,LinphoneReasonDeclined); + case LinphoneCallOutgoingInit: { + /* In state OutgoingInit, op has to be destroyed */ + sal_op_release(call->op); + call->op = NULL; + break; + } - if (call->state != LinphoneCallOutgoingInit) + default: sal_call_terminate(call->op); - else { - /* In state OutgoingInit, op has to be destroyed */ - sal_op_release(call->op); - call->op = NULL; + break; } + terminate_call(lc,call); return 0; }