[Freeswitch-trunk] [commit] r6780 - freeswitch/trunk/src/mod/dialplans/mod_dialplan_asterisk

Freeswitch SVN mikej at freeswitch.org
Thu Dec 13 19:52:28 EST 2007


Author: mikej
Date: Thu Dec 13 19:52:27 2007
New Revision: 6780

Modified:
   freeswitch/trunk/src/mod/dialplans/mod_dialplan_asterisk/mod_dialplan_asterisk.c

Log:
cleanup, null checks. etc.


Modified: freeswitch/trunk/src/mod/dialplans/mod_dialplan_asterisk/mod_dialplan_asterisk.c
==============================================================================
--- freeswitch/trunk/src/mod/dialplans/mod_dialplan_asterisk/mod_dialplan_asterisk.c	(original)
+++ freeswitch/trunk/src/mod/dialplans/mod_dialplan_asterisk/mod_dialplan_asterisk.c	Thu Dec 13 19:52:27 2007
@@ -185,7 +185,7 @@
 				char *pattern = NULL;
 				char *pri = NULL;
 				char *app = NULL;
-				char *arg = NULL;
+				char *argument = NULL;
 				char *expression = NULL, expression_buf[1024] = "";
 				char substituted[2048] = "";
 				char *field_data = caller_profile->destination_number;
@@ -206,7 +206,7 @@
 				
 				if (!strcasecmp(var, "exten")) {
 					char *p;
-					if ((p = strchr(pattern, '/'))) {
+					if (pattern && (p = strchr(pattern, '/'))) {
 						*p++ = '\0';
 						cid = pattern;
 						pattern = p;
@@ -224,7 +224,7 @@
 					}
 				}
 				
-				if (*pattern == '_' || *pattern == '~') {
+				if (pattern && (*pattern == '_' || *pattern == '~')) {
 					if (*pattern == '_') {
 						pattern++;
 						if (switch_ast2regex(pattern, expression_buf, sizeof(expression_buf))) {
@@ -242,7 +242,7 @@
 						continue;
 					}
 				} else {
-					if (strcasecmp(pattern, field_data)) {
+					if (pattern && strcasecmp(pattern, field_data)) {
 						continue;
 					}
 				}
@@ -260,24 +260,24 @@
 				pri = argv[1];
 				app = argv[2];
 				
-				if ((arg = strchr(app, '('))) {
+				if ((argument = strchr(app, '('))) {
 					char *p;
-					*arg++ = '\0';
-					p = strrchr(arg, ')');
+					*argument++ = '\0';
+					p = strrchr(argument, ')');
 					if (p) {
 							*p = '\0';
 					}
-				} else if ((arg = strchr(app, ','))) {
-					*arg++ = '\0';
+				} else if ((argument = strchr(app, ','))) {
+					*argument++ = '\0';
 				}
 				
-				if (!arg) {
-					arg = "";
+				if (!argument) {
+					argument = "";
 				}
 
 				if (strchr(expression, '(')) {
-					switch_perform_substitution(re, proceed, arg, field_data, substituted, sizeof(substituted), ovector);
-					arg = substituted;
+					switch_perform_substitution(re, proceed, argument, field_data, substituted, sizeof(substituted), ovector);
+					argument = substituted;
 				}
 				switch_regex_safe_free(re);
 
@@ -288,7 +288,7 @@
 					}
 				}
 				
-				switch_caller_extension_add_application(session, extension, app, arg);
+				switch_caller_extension_add_application(session, extension, app, argument);
 			}
 			
 			switch_safe_free(field_expanded);



More information about the Freeswitch-trunk mailing list