diff options
author | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-04-23 18:19:42 +0000 |
---|---|---|
committer | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-04-23 18:19:42 +0000 |
commit | f611270cd8cbce58efa1ef5f76d9622e4089cec5 (patch) | |
tree | 416b642471f91f83ca906c1760c4f64510ff655b /main | |
parent | b4587469dac012d31a91a5949e54af4f67d76d62 (diff) |
Merged revisions 61765 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r61765 | russell | 2007-04-23 13:17:00 -0500 (Mon, 23 Apr 2007) | 5 lines
Some dialplan functions, such as CUT(), expect to operate on variables on a
channel. So, this little hack lets them work in places where a channel doesn't
exist, such as within DUNDi configuration.
(issue #9465, reported and patched by Corydon76, testing by blitzrage)
........
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@61766 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main')
-rw-r--r-- | main/pbx.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/main/pbx.c b/main/pbx.c index e916411ff..0e4464a63 100644 --- a/main/pbx.c +++ b/main/pbx.c @@ -1564,7 +1564,21 @@ static void pbx_substitute_variables_helper_full(struct ast_channel *c, struct v parse_variable_name(vars, &offset, &offset2, &isfunction); if (isfunction) { /* Evaluate function */ - cp4 = ast_func_read(c, vars, workspace, VAR_BUF_SIZE) ? NULL : workspace; + if (c) + cp4 = ast_func_read(c, vars, workspace, VAR_BUF_SIZE) ? NULL : workspace; + else { + struct varshead old; + struct ast_channel *c = ast_channel_alloc(0, 0, "", "", "", "", "", 0, "Bogus/%p", vars); + if (c) { + memcpy(&old, &c->varshead, sizeof(old)); + memcpy(&c->varshead, headp, sizeof(c->varshead)); + cp4 = ast_func_read(c, vars, workspace, VAR_BUF_SIZE) ? NULL : workspace; + /* Don't deallocate the varshead that was passed in */ + memcpy(&c->varshead, &old, sizeof(c->varshead)); + ast_channel_free(c); + } else + ast_log(LOG_ERROR, "Unable to allocate bogus channel for variable substitution. Function results may be blank.\n"); + } if (option_debug) ast_log(LOG_DEBUG, "Function result is '%s'\n", cp4 ? cp4 : "(null)"); } else { |