Fix crash when trying to cancel a non-existing INVITE transaction.

This commit is contained in:
Simon Morlat 2018-03-19 17:52:34 +01:00
parent 29f9de93a3
commit c38a2e0c77
3 changed files with 17 additions and 7 deletions

View file

@ -821,8 +821,9 @@ void CallSessionPrivate::repairIfBroken () {
case CallSession::State::Pausing:
if (op->dialog_request_pending()) {
// Need to cancel first re-INVITE as described in section 5.5 of RFC 6141
op->cancel_invite();
reinviteOnCancelResponseRequested = true;
if (op->cancel_invite() == 0){
reinviteOnCancelResponseRequested = true;
}
}
break;
case CallSession::State::StreamsRunning:
@ -840,8 +841,9 @@ void CallSessionPrivate::repairIfBroken () {
break;
case CallSession::State::OutgoingInit:
case CallSession::State::OutgoingProgress:
op->cancel_invite();
reinviteOnCancelResponseRequested = true;
if (op->cancel_invite() == 0){
reinviteOnCancelResponseRequested = true;
}
break;
case CallSession::State::OutgoingEarlyMedia:
case CallSession::State::OutgoingRinging:

View file

@ -1120,9 +1120,15 @@ int SalCallOp::update(const char *subject, bool_t no_user_consent) {
return -1;
}
void SalCallOp::cancel_invite_with_info(const SalErrorInfo *info) {
int SalCallOp::cancel_invite_with_info(const SalErrorInfo *info) {
belle_sip_request_t* cancel;
ms_message("Cancelling INVITE request from [%s] to [%s] ",get_from(), get_to());
if (this->pending_client_trans == NULL){
ms_warning("There is no transaction to cancel.");
return -1;
}
cancel = belle_sip_client_transaction_create_cancel(this->pending_client_trans);
if (cancel){
if (info != NULL){
@ -1130,6 +1136,7 @@ void SalCallOp::cancel_invite_with_info(const SalErrorInfo *info) {
belle_sip_message_add_header(BELLE_SIP_MESSAGE(cancel),BELLE_SIP_HEADER(reason));
}
send_request(cancel);
return 0;
}else if (this->dialog){
belle_sip_dialog_state_t state = belle_sip_dialog_get_state(this->dialog);;
/*case where the response received is invalid (could not establish a dialog), but the transaction is not cancellable
@ -1145,6 +1152,7 @@ void SalCallOp::cancel_invite_with_info(const SalErrorInfo *info) {
break;
}
}
return -1;
}
SalMediaDescription *SalCallOp::get_final_media_description() {

View file

@ -45,8 +45,8 @@ public:
int decline(SalReason reason, const char *redirection /*optional*/);
int decline_with_error_info(const SalErrorInfo *info, const SalAddress *redirectionAddr /*optional*/);
int update(const char *subject, bool_t no_user_consent);
void cancel_invite() {cancel_invite_with_info(NULL);}
void cancel_invite_with_info(const SalErrorInfo *info);
int cancel_invite() { return cancel_invite_with_info(NULL);}
int cancel_invite_with_info(const SalErrorInfo *info);
int refer(const char *refer_to_);
int refer_with_replaces(SalCallOp *other_call_op);
int set_referer(SalCallOp *refered_call);