diff --git a/src/switch_ivr_originate.c b/src/switch_ivr_originate.c index 8ed77d188d..70d739e9a7 100644 --- a/src/switch_ivr_originate.c +++ b/src/switch_ivr_originate.c @@ -268,9 +268,11 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_wait_for_answer(switch_core_session_t switch_frame_t *read_frame = NULL; switch_status_t status = SWITCH_STATUS_SUCCESS; int timelimit = 60; - const char *var = switch_channel_get_variable(caller_channel, "call_timeout"); + const char *var; switch_time_t start = 0; + switch_assert(peer_channel); + if (session) { caller_channel = switch_core_session_get_channel(session); } @@ -282,7 +284,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_wait_for_answer(switch_core_session_t switch_zmalloc(write_frame.data, SWITCH_RECOMMENDED_BUFFER_SIZE); write_frame.buflen = SWITCH_RECOMMENDED_BUFFER_SIZE; - if (var) { + if (caller_channel && (var = switch_channel_get_variable(caller_channel, "call_timeout"))) { timelimit = atoi(var); if (timelimit < 0) { timelimit = 60;