From 54c589500925106ed05de3331d195a0a3cafa366 Mon Sep 17 00:00:00 2001 From: Dragos Oancea Date: Mon, 25 Mar 2019 19:22:23 +0000 Subject: [PATCH] FS-11951: JB: rare crash in reading the chan var (it maybe called without a session in some unit tests) --- src/switch_jitterbuffer.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/switch_jitterbuffer.c b/src/switch_jitterbuffer.c index f27b5ee8e1..8eabe61aba 100644 --- a/src/switch_jitterbuffer.c +++ b/src/switch_jitterbuffer.c @@ -880,18 +880,17 @@ SWITCH_DECLARE(void) switch_jb_set_session(switch_jb_t *jb, switch_core_session_ { const char *var; - jb->session = session; - jb->channel = switch_core_session_get_channel(session); - - if (jb->type == SJB_VIDEO && !switch_test_flag(jb, SJB_QUEUE_ONLY) && - (var = switch_channel_get_variable_dup(jb->channel, "jb_video_low_bitrate", SWITCH_FALSE, -1))) { - int tmp = atoi(var); - - if (tmp >= 128 && tmp <= 10240) { - jb->video_low_bitrate = (uint32_t)tmp; + if (session) { + jb->session = session; + jb->channel = switch_core_session_get_channel(session); + if (jb->type == SJB_VIDEO && !switch_test_flag(jb, SJB_QUEUE_ONLY) && + (var = switch_channel_get_variable_dup(jb->channel, "jb_video_low_bitrate", SWITCH_FALSE, -1))) { + int tmp = atoi(var); + if (tmp >= 128 && tmp <= 10240) { + jb->video_low_bitrate = (uint32_t)tmp; + } } } - } SWITCH_DECLARE(void) switch_jb_set_flag(switch_jb_t *jb, switch_jb_flag_t flag)