summaryrefslogtreecommitdiff
path: root/pbx.c
diff options
context:
space:
mode:
authorMark Spencer <markster@digium.com>2003-10-26 23:08:21 +0000
committerMark Spencer <markster@digium.com>2003-10-26 23:08:21 +0000
commit6e445e39a1e66af3f9aa1cf3ad5f64e1e5129e4b (patch)
treecabe731fca12b42500073f43ba996d2c59e0bd30 /pbx.c
parentc420eb06eabd84453a788be127e68d32dcbc798e (diff)
Make sure variables exists (bug #409)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@1675 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'pbx.c')
-rwxr-xr-xpbx.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/pbx.c b/pbx.c
index cda3dd035..c29bed7cf 100755
--- a/pbx.c
+++ b/pbx.c
@@ -3833,12 +3833,12 @@ int ast_pbx_outgoing_exten(char *type, int format, void *data, int timeout, char
strncpy(chan->context, context, sizeof(chan->context) - 1);
strncpy(chan->exten, "failed", sizeof(chan->exten) - 1);
chan->priority = 1;
- /* JDG chanvar */
- tmp = variable;
- /* FIXME replace this call with strsep NOT*/
- while( (var = strtok_r(NULL, "|", &tmp)) ) {
- pbx_builtin_setvar( chan, var );
- } /* /JDG */
+ if (variable) {
+ tmp = ast_strdupa(variable);
+ for (var = strtok_r(tmp, "|", &tmp); var; var = strtok_r(NULL, "|", &tmp)) {
+ pbx_builtin_setvar( chan, var );
+ }
+ }
ast_pbx_run(chan);
} else
ast_log(LOG_WARNING, "Can't allocate the channel structure, skipping execution of extension 'failed'\n");
@@ -3909,9 +3909,11 @@ int ast_pbx_outgoing_app(char *type, int format, void *data, int timeout, char *
if (sync) {
chan = ast_request_and_dial(type, format, data, timeout, reason, callerid);
if (chan) {
- vartmp = variable;
- while( (var = strtok_r(NULL, "|", &vartmp)) ) {
- pbx_builtin_setvar( chan, var );
+ if (variable) {
+ vartmp = ast_strdupa(variable);
+ for (var = strtok_r(vartmp, "|", &vartmp); var; var = strtok_r(NULL, "|", &vartmp)) {
+ pbx_builtin_setvar( chan, var );
+ }
}
if (chan->_state == AST_STATE_UP) {
res = 0;