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

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Mar 18 23:14:12 CDT 2008


Author: russell
Date: Tue Mar 18 23:14:12 2008
New Revision: 109842

URL: http://svn.digium.com/view/asterisk?view=rev&rev=109842
Log:
Minor coding style changes, including adding handling for memory allocation failure

Modified:
    trunk/main/pbx.c

Modified: trunk/main/pbx.c
URL: http://svn.digium.com/view/asterisk/trunk/main/pbx.c?view=diff&rev=109842&r1=109841&r2=109842
==============================================================================
--- trunk/main/pbx.c (original)
+++ trunk/main/pbx.c Tue Mar 18 23:14:12 2008
@@ -1091,19 +1091,30 @@
 static struct match_char *already_in_tree(struct match_char *current, char *pat)
 {
 	struct match_char *t;
+
 	if (!current)
 		return 0;
-	for (t=current; t; t=t->alt_char) {
-		if (strcmp(pat,t->x) == 0) /* uh, we may want to sort exploded [] contents to make matching easy */
+
+	for (t = current; t; t = t->alt_char) {
+		if (!strcmp(pat, t->x)) /* uh, we may want to sort exploded [] contents to make matching easy */
 			return t;
 	}
+
 	return 0;
 }
 
 static struct match_char *add_pattern_node(struct ast_context *con, struct match_char *current, char *pattern, int is_pattern, int already, int specificity)
 {
-	struct match_char *m = ast_calloc(1,sizeof(struct match_char));
-	m->x = ast_strdup(pattern);
+	struct match_char *m;
+	
+	if (!(m = ast_calloc(1, sizeof(*m))))
+		return NULL;
+
+	if (!(m->x = ast_strdup(pattern))) {
+		ast_free(m);
+		return NULL;
+	}
+
 	m->is_pattern = is_pattern;
 	if (specificity == 1 && is_pattern && pattern[0] == 'N')
 		m->specificity = 98;
@@ -1133,6 +1144,7 @@
 			}
 		}
 	}
+
 	return m;
 }
 




More information about the asterisk-commits mailing list