From: Igor Goncharovskiy Date: Thu, 30 Oct 2014 06:02:10 +0000 (+0000) Subject: Add additional checks for NULL pointers to fix several crashes reported. X-Git-Tag: 12.7.0-rc1~18 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a2dce2e446a4841c4fad0661f7e2e562ed26ee68;p=thirdparty%2Fasterisk.git Add additional checks for NULL pointers to fix several crashes reported. ASTERISK-24304 #close Reported by: dhanapathy sathya ........ Merged revisions 426666 from http://svn.asterisk.org/svn/asterisk/branches/11 git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/12@426667 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/channels/chan_unistim.c b/channels/chan_unistim.c index 411390d1a7..3990cf61d1 100644 --- a/channels/chan_unistim.c +++ b/channels/chan_unistim.c @@ -2516,6 +2516,9 @@ static void *unistim_ss(void *data) struct unistimsession *s = l->parent->session; int res; + if (!s) { + return NULL; + } ast_verb(3, "Starting switch on '%s@%s-%d' to %s\n", l->name, l->parent->name, sub->softkey, s->device->phone_number); ast_channel_lock(chan); ast_channel_exten_set(chan, s->device->phone_number); @@ -3283,6 +3286,9 @@ static void key_call(struct unistimsession *pte, char keycode) struct unistim_subchannel *sub = get_sub(pte->device, SUB_REAL); struct unistim_subchannel *sub_3way = get_sub(pte->device, SUB_THREEWAY); + if (!sub) { + return; + } if ((keycode >= KEY_0) && (keycode <= KEY_SHARP)) { if (keycode == KEY_SHARP) { keycode = '#'; @@ -3296,7 +3302,7 @@ static void key_call(struct unistimsession *pte, char keycode) } switch (keycode) { case KEY_FUNC1: - if (ast_channel_state(sub->owner) == AST_STATE_UP) { + if (sub->owner && ast_channel_state(sub->owner) == AST_STATE_UP) { if (sub_3way) { close_call(pte); } @@ -3338,8 +3344,8 @@ static void key_call(struct unistimsession *pte, char keycode) MUTE_OFF); break; case KEY_MUTE: - if (!sub || !sub->owner) { - ast_log(LOG_WARNING, "Unable to find subchannel for music on hold\n"); + if (!sub->owner) { + ast_log(LOG_WARNING, "Unable to find channel for music on hold\n"); return; } if (!sub->moh) {