diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c index 777b23fad9..3ded1dccd2 100644 --- a/src/mod/endpoints/mod_sofia/sofia.c +++ b/src/mod/endpoints/mod_sofia/sofia.c @@ -748,7 +748,8 @@ void sofia_handle_sip_r_message(int status, sofia_profile_t *profile, nua_handle const char *call_id; int *mstatus; - if (!sip && sip->sip_call_id) { + if (!(sip && sip->sip_call_id)) { + nua_handle_destroy(nh); return; } diff --git a/src/mod/endpoints/mod_sofia/sofia_presence.c b/src/mod/endpoints/mod_sofia/sofia_presence.c index f147d6d471..e53a4fd267 100644 --- a/src/mod/endpoints/mod_sofia/sofia_presence.c +++ b/src/mod/endpoints/mod_sofia/sofia_presence.c @@ -357,7 +357,7 @@ switch_status_t sofia_presence_chat_send(switch_event_t *message_event) if (is_blocking) { sanity = 200; - while(!mstatus && --sanity) { + while(!mstatus && --sanity && !msg_nh->nh_destroyed) { switch_yield(100000); }