From: Mark Michelson Date: Wed, 20 Feb 2008 21:40:08 +0000 (+0000) Subject: Fix a crash if the channel becomes NULL while attempting to lock it. X-Git-Tag: 1.4.19~157 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6835ca7d03159588d9e2d5f605c62476e96f7cf2;p=thirdparty%2Fasterisk.git Fix a crash if the channel becomes NULL while attempting to lock it. (closes issue #12039) Reported by: danpwi git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@103904 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/channels/chan_local.c b/channels/chan_local.c index 9ea0018b21..5a8d6f002d 100644 --- a/channels/chan_local.c +++ b/channels/chan_local.c @@ -503,13 +503,15 @@ static int local_hangup(struct ast_channel *ast) const char *status = pbx_builtin_getvar_helper(p->chan, "DIALSTATUS"); if ((status) && (p->owner)) { /* Deadlock avoidance */ - while (ast_channel_trylock(p->owner)) { + while (p->owner && ast_channel_trylock(p->owner)) { ast_mutex_unlock(&p->lock); usleep(1); ast_mutex_lock(&p->lock); } - pbx_builtin_setvar_helper(p->owner, "CHANLOCALSTATUS", status); - ast_channel_unlock(p->owner); + if (p->owner) { + pbx_builtin_setvar_helper(p->owner, "CHANLOCALSTATUS", status); + ast_channel_unlock(p->owner); + } } p->chan = NULL; ast_clear_flag(p, LOCAL_LAUNCHED_PBX);