diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c index 4dfb4f8a68..505c63a08e 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.c +++ b/src/mod/endpoints/mod_sofia/mod_sofia.c @@ -636,7 +636,9 @@ static switch_status_t sofia_kill_channel(switch_core_session_t *session, int si { private_object_t *tech_pvt = switch_core_session_get_private(session); - switch_assert(tech_pvt != NULL); + if (!tech_pvt) { + return SWITCH_STATUS_FALSE; + } switch (sig) { case SWITCH_SIG_BREAK: diff --git a/src/switch_core_io.c b/src/switch_core_io.c index 8c7ba6a6c1..cb93861ec1 100644 --- a/src/switch_core_io.c +++ b/src/switch_core_io.c @@ -40,6 +40,11 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_write_video_frame(switch_cor switch_io_event_hook_video_write_frame_t *ptr; switch_status_t status = SWITCH_STATUS_FALSE; switch_io_flag_t flags = 0; + + if (switch_channel_get_state(session->channel) >= CS_HANGUP) { + return SWITCH_STATUS_FALSE; + } + if (session->endpoint_interface->io_routines->write_video_frame) { if ((status = session->endpoint_interface->io_routines->write_video_frame(session, frame, timeout, flags, stream_id)) == SWITCH_STATUS_SUCCESS) { for (ptr = session->event_hooks.video_write_frame; ptr; ptr = ptr->next) { @@ -57,6 +62,10 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_video_frame(switch_core switch_status_t status = SWITCH_STATUS_FALSE; switch_io_event_hook_video_read_frame_t *ptr; + if (switch_channel_get_state(session->channel) >= CS_HANGUP) { + return SWITCH_STATUS_FALSE; + } + if (session->endpoint_interface->io_routines->read_video_frame) { if ((status = session->endpoint_interface->io_routines->read_video_frame(session, frame, timeout, SWITCH_IO_FLAG_NOOP, stream_id)) == SWITCH_STATUS_SUCCESS) { @@ -97,6 +106,11 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_frame(switch_core_sessi unsigned int flag = 0; top: + if (switch_channel_get_state(session->channel) >= CS_HANGUP) { + return SWITCH_STATUS_FALSE; + } + + status = SWITCH_STATUS_FALSE; need_codec = perfect = 0; @@ -466,6 +480,9 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_write_frame(switch_core_sess switch_assert(session != NULL); switch_assert(frame != NULL); + if (switch_channel_get_state(session->channel) >= CS_HANGUP) { + return SWITCH_STATUS_FALSE; + } if (switch_channel_test_flag(session->channel, CF_HOLD)) { return SWITCH_STATUS_SUCCESS; @@ -917,6 +934,10 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_recv_dtmf(switch_core_sessio switch_status_t status; switch_dtmf_t new_dtmf; + if (switch_channel_get_state(session->channel) >= CS_HANGUP) { + return SWITCH_STATUS_FALSE; + } + switch_assert(dtmf); new_dtmf = *dtmf; @@ -943,6 +964,10 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_send_dtmf(switch_core_sessio switch_status_t status = SWITCH_STATUS_FALSE; switch_dtmf_t new_dtmf; + if (switch_channel_get_state(session->channel) >= CS_HANGUP) { + return SWITCH_STATUS_FALSE; + } + switch_assert(dtmf); new_dtmf = *dtmf; @@ -983,9 +1008,13 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_send_dtmf_string(switch_core int i, argc; char *argv[256]; - switch_assert(session != NULL); + + if (switch_channel_get_state(session->channel) >= CS_HANGUP) { + return SWITCH_STATUS_FALSE; + } + if (switch_strlen_zero(dtmf_string)) { return SWITCH_STATUS_FALSE; }