[asterisk-commits] russell: trunk r61766 - in /trunk: ./ main/pbx.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Mon Apr 23 11:19:43 MST 2007


Author: russell
Date: Mon Apr 23 13:19:42 2007
New Revision: 61766

URL: http://svn.digium.com/view/asterisk?view=rev&rev=61766
Log:
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)

........

Modified:
    trunk/   (props changed)
    trunk/main/pbx.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Modified: trunk/main/pbx.c
URL: http://svn.digium.com/view/asterisk/trunk/main/pbx.c?view=diff&rev=61766&r1=61765&r2=61766
==============================================================================
--- trunk/main/pbx.c (original)
+++ trunk/main/pbx.c Mon Apr 23 13:19:42 2007
@@ -1564,7 +1564,21 @@
 			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 {



More information about the asterisk-commits mailing list