diff options
author | Jonathan Rose <jrose@digium.com> | 2013-09-20 22:06:07 +0000 |
---|---|---|
committer | Jonathan Rose <jrose@digium.com> | 2013-09-20 22:06:07 +0000 |
commit | 638577bef707f9c4964ea672aafe95d5d4509df3 (patch) | |
tree | 48898e8b039a046f13501196857d36ccfb8c1ced | |
parent | d4a026a0ee70b06455c26a134780744bba08e64b (diff) |
originate/call forwarding: Fix a crash when forwarding a call from originate
(closes issue ASTERISK-22487)
Reported by: David M. Lee
Review: https://reviewboard.asterisk.org/r/2868/
........
Merged revisions 399553 from http://svn.asterisk.org/svn/asterisk/branches/12
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@399554 65c4cc65-6c06-0410-ace0-fbb531ad65f3
-rw-r--r-- | main/dial.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/main/dial.c b/main/dial.c index e13805ad4..3b720fb9f 100644 --- a/main/dial.c +++ b/main/dial.c @@ -398,6 +398,15 @@ static int handle_call_forward(struct ast_dial *dial, struct ast_dial_channel *c *stuff++ = '\0'; tech = tmp; device = stuff; + } else { + const char *forward_context; + char destination[AST_MAX_CONTEXT + AST_MAX_EXTENSION + 1]; + + ast_channel_lock(original); + forward_context = pbx_builtin_getvar_helper(original, "FORWARD_CONTEXT"); + snprintf(destination, sizeof(destination), "%s@%s", tmp, S_OR(forward_context, ast_channel_context(original))); + ast_channel_unlock(original); + device = ast_strdupa(destination); } /* Drop old destination information */ @@ -409,11 +418,13 @@ static int handle_call_forward(struct ast_dial *dial, struct ast_dial_channel *c channel->device = ast_strdup(device); AST_LIST_UNLOCK(&dial->channels); - /* Finally give it a go... send it out into the world */ - begin_dial_channel(channel, chan, chan ? 0 : 1); /* Drop the original channel */ ast_hangup(original); + channel->owner = NULL; + + /* Finally give it a go... send it out into the world */ + begin_dial_channel(channel, chan, chan ? 0 : 1); return 0; } |