[Asterisk-cvs] asterisk pbx.c,1.62,1.63

markster at lists.digium.com markster at lists.digium.com
Sun Oct 26 16:42:15 CST 2003


Update of /usr/cvsroot/asterisk
In directory mongoose.digium.com:/tmp/cvs-serv13737

Modified Files:
	pbx.c 
Log Message:
Make sure variables exists (bug #409)


Index: pbx.c
===================================================================
RCS file: /usr/cvsroot/asterisk/pbx.c,v
retrieving revision 1.62
retrieving revision 1.63
diff -u -d -r1.62 -r1.63
--- pbx.c	25 Oct 2003 18:00:00 -0000	1.62
+++ pbx.c	26 Oct 2003 23:08:21 -0000	1.63
@@ -3833,12 +3833,12 @@
 						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 @@
 	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;




More information about the svn-commits mailing list