[asterisk-commits] wdoekes: trunk r396309 - in /trunk: ./ apps/ funcs/ main/ pbx/ utils/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Aug 6 03:36:28 CDT 2013


Author: wdoekes
Date: Tue Aug  6 03:36:15 2013
New Revision: 396309

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=396309
Log:
Check result of ast_var_assign() calls for memory allocation failure.

We try to keep the system running even when all available memory is
spent.

Review: https://reviewboard.asterisk.org/r/2734/
........

Merged revisions 396279 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 396287 from http://svn.asterisk.org/svn/asterisk/branches/11

Modified:
    trunk/   (props changed)
    trunk/apps/app_playback.c
    trunk/apps/app_stack.c
    trunk/funcs/func_global.c
    trunk/funcs/func_strings.c
    trunk/main/cdr.c
    trunk/main/pbx.c
    trunk/pbx/pbx_dundi.c
    trunk/pbx/pbx_loopback.c
    trunk/utils/extconf.c

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

Modified: trunk/apps/app_playback.c
URL: http://svnview.digium.com/svn/asterisk/trunk/apps/app_playback.c?view=diff&rev=396309&r1=396308&r2=396309
==============================================================================
--- trunk/apps/app_playback.c (original)
+++ trunk/apps/app_playback.c Tue Aug  6 03:36:15 2013
@@ -220,6 +220,10 @@
 		s = x + 1;
 	ast_debug(2, "value is <%s>\n", s);
 	n = ast_var_assign("SAY", s);
+	if (!n) {
+		ast_log(LOG_ERROR, "Memory allocation error in do_say\n");
+		return -1;
+	}
 	AST_LIST_INSERT_HEAD(&head, n, entries);
 
 	/* scan the body, one piece at a time */

Modified: trunk/apps/app_stack.c
URL: http://svnview.digium.com/svn/asterisk/trunk/apps/app_stack.c?view=diff&rev=396309&r1=396308&r2=396309
==============================================================================
--- trunk/apps/app_stack.c (original)
+++ trunk/apps/app_stack.c Tue Aug  6 03:36:15 2013
@@ -273,8 +273,9 @@
 	}
 
 	if (!found) {
-		variables = ast_var_assign(var, "");
-		AST_LIST_INSERT_HEAD(&frame->varshead, variables, entries);
+		if ((variables = ast_var_assign(var, ""))) {
+			AST_LIST_INSERT_HEAD(&frame->varshead, variables, entries);
+		}
 		pbx_builtin_pushvar_helper(chan, var, value);
 	} else {
 		pbx_builtin_setvar_helper(chan, var, value);

Modified: trunk/funcs/func_global.c
URL: http://svnview.digium.com/svn/asterisk/trunk/funcs/func_global.c?view=diff&rev=396309&r1=396308&r2=396309
==============================================================================
--- trunk/funcs/func_global.c (original)
+++ trunk/funcs/func_global.c Tue Aug  6 03:36:15 2013
@@ -282,11 +282,12 @@
 	}
 	AST_LIST_TRAVERSE_SAFE_END;
 
-	var = ast_var_assign(args.var, S_OR(value, ""));
-	AST_LIST_INSERT_HEAD(varshead, var, entries);
-
-	sprintf(shared_buffer, "SHARED(%s)", args.var);
-	ast_channel_publish_varset(chan, shared_buffer, value);
+	if ((var = ast_var_assign(args.var, S_OR(value, "")))) {
+		AST_LIST_INSERT_HEAD(varshead, var, entries);
+
+		sprintf(shared_buffer, "SHARED(%s)", args.var);
+		ast_channel_publish_varset(chan, shared_buffer, value);
+	}
 
 	ast_channel_unlock(chan);
 

Modified: trunk/funcs/func_strings.c
URL: http://svnview.digium.com/svn/asterisk/trunk/funcs/func_strings.c?view=diff&rev=396309&r1=396308&r2=396309
==============================================================================
--- trunk/funcs/func_strings.c (original)
+++ trunk/funcs/func_strings.c Tue Aug  6 03:36:15 2013
@@ -1698,6 +1698,12 @@
 
 	for (i = 0; i < ARRAY_LEN(test_args); i++) {
 		struct ast_var_t *var = ast_var_assign("FIELDS", test_args[i].fields);
+		if (!var) {
+			ast_test_status_update(test, "Out of memory\n");
+			res = AST_TEST_FAIL;
+			break;
+		}
+
 		AST_LIST_INSERT_HEAD(ast_channel_varshead(chan), var, entries);
 
 		snprintf(expression, sizeof(expression), "${FIELDNUM(%s,%s,%s)}", var->name, test_args[i].delim, test_args[i].field);

Modified: trunk/main/cdr.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/cdr.c?view=diff&rev=396309&r1=396308&r2=396309
==============================================================================
--- trunk/main/cdr.c (original)
+++ trunk/main/cdr.c Tue Aug  6 03:36:15 2013
@@ -699,8 +699,8 @@
 	AST_LIST_TRAVERSE(from_list, variables, entries) {
 		if (variables &&
 		    (var = ast_var_name(variables)) && (val = ast_var_value(variables)) &&
-		    !ast_strlen_zero(var) && !ast_strlen_zero(val)) {
-			newvariable = ast_var_assign(var, val);
+		    !ast_strlen_zero(var) && !ast_strlen_zero(val) &&
+		    (newvariable = ast_var_assign(var, val))) {
 			AST_LIST_INSERT_HEAD(to_list, newvariable, entries);
 			x++;
 		}
@@ -1033,8 +1033,7 @@
 	}
 	AST_LIST_TRAVERSE_SAFE_END;
 
-	if (value) {
-		newvariable = ast_var_assign(name, value);
+	if (value && (newvariable = ast_var_assign(name, value))) {
 		AST_LIST_INSERT_HEAD(headp, newvariable, entries);
 	}
 }
@@ -1113,15 +1112,15 @@
 		copy_variables(&cdr_copy->varshead, &it_cdr->party_a.variables);
 		AST_LIST_TRAVERSE(&it_cdr->party_b.variables, it_var, entries) {
 			int found = 0;
+			struct ast_var_t *newvariable;
 			AST_LIST_TRAVERSE(&cdr_copy->varshead, it_copy_var, entries) {
 				if (!strcmp(ast_var_name(it_var), ast_var_name(it_copy_var))) {
 					found = 1;
 					break;
 				}
 			}
-			if (!found) {
-				AST_LIST_INSERT_TAIL(&cdr_copy->varshead, ast_var_assign(ast_var_name(it_var),
-						ast_var_value(it_var)), entries);
+			if (!found && (newvariable = ast_var_assign(ast_var_name(it_var), ast_var_value(it_var)))) {
+				AST_LIST_INSERT_TAIL(&cdr_copy->varshead, newvariable, entries);
 			}
 		}
 

Modified: trunk/main/pbx.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/pbx.c?view=diff&rev=396309&r1=396308&r2=396309
==============================================================================
--- trunk/main/pbx.c (original)
+++ trunk/main/pbx.c Tue Aug  6 03:36:15 2013
@@ -10911,10 +10911,9 @@
 		headp = &globals;
 	}
 
-	if (value) {
+	if (value && (newvariable = ast_var_assign(name, value))) {
 		if (headp == &globals)
 			ast_verb(2, "Setting global variable '%s' to '%s'\n", name, value);
-		newvariable = ast_var_assign(name, value);
 		AST_LIST_INSERT_HEAD(headp, newvariable, entries);
 	}
 
@@ -10961,10 +10960,9 @@
 	}
 	AST_LIST_TRAVERSE_SAFE_END;
 
-	if (value) {
+	if (value && (newvariable = ast_var_assign(name, value))) {
 		if (headp == &globals)
 			ast_verb(2, "Setting global variable '%s' to '%s'\n", name, value);
-		newvariable = ast_var_assign(name, value);
 		AST_LIST_INSERT_HEAD(headp, newvariable, entries);
 		ast_channel_publish_varset(chan, name, value);
 

Modified: trunk/pbx/pbx_dundi.c
URL: http://svnview.digium.com/svn/asterisk/trunk/pbx/pbx_dundi.c?view=diff&rev=396309&r1=396308&r2=396309
==============================================================================
--- trunk/pbx/pbx_dundi.c (original)
+++ trunk/pbx/pbx_dundi.c Tue Aug  6 03:36:15 2013
@@ -607,14 +607,18 @@
 			ast_eid_to_str(dr[anscnt].eid_str, sizeof(dr[anscnt].eid_str), &dr[anscnt].eid);
 			if (ast_test_flag(&flags, DUNDI_FLAG_EXISTS)) {
 				AST_LIST_HEAD_INIT_NOLOCK(&headp);
-				newvariable = ast_var_assign("NUMBER", called_number);
-				AST_LIST_INSERT_HEAD(&headp, newvariable, entries);
-				newvariable = ast_var_assign("EID", dr[anscnt].eid_str);
-				AST_LIST_INSERT_HEAD(&headp, newvariable, entries);
-				newvariable = ast_var_assign("SECRET", cursecret);
-				AST_LIST_INSERT_HEAD(&headp, newvariable, entries);
-				newvariable = ast_var_assign("IPADDR", ipaddr);
-				AST_LIST_INSERT_HEAD(&headp, newvariable, entries);
+				if ((newvariable = ast_var_assign("NUMBER", called_number))) {
+					AST_LIST_INSERT_HEAD(&headp, newvariable, entries);
+				}
+				if ((newvariable = ast_var_assign("EID", dr[anscnt].eid_str))) {
+					AST_LIST_INSERT_HEAD(&headp, newvariable, entries);
+				}
+				if ((newvariable = ast_var_assign("SECRET", cursecret))) {
+					AST_LIST_INSERT_HEAD(&headp, newvariable, entries);
+				}
+				if ((newvariable = ast_var_assign("IPADDR", ipaddr))) {
+					AST_LIST_INSERT_HEAD(&headp, newvariable, entries);
+				}
 				pbx_substitute_variables_varshead(&headp, map->dest, dr[anscnt].dest, sizeof(dr[anscnt].dest));
 				dr[anscnt].weight = get_mapping_weight(map, &headp);
 				while ((newvariable = AST_LIST_REMOVE_HEAD(&headp, entries)))

Modified: trunk/pbx/pbx_loopback.c
URL: http://svnview.digium.com/svn/asterisk/trunk/pbx/pbx_loopback.c?view=diff&rev=396309&r1=396308&r2=396309
==============================================================================
--- trunk/pbx/pbx_loopback.c (original)
+++ trunk/pbx/pbx_loopback.c Tue Aug  6 03:36:15 2013
@@ -91,12 +91,15 @@
 
 	snprintf(tmp, sizeof(tmp), "%d", priority);
 	AST_LIST_HEAD_INIT_NOLOCK(&headp);
-	newvariable = ast_var_assign("EXTEN", exten);
-	AST_LIST_INSERT_HEAD(&headp, newvariable, entries);
-	newvariable = ast_var_assign("CONTEXT", context);
-	AST_LIST_INSERT_HEAD(&headp, newvariable, entries);
-	newvariable = ast_var_assign("PRIORITY", tmp);
-	AST_LIST_INSERT_HEAD(&headp, newvariable, entries);
+	if ((newvariable = ast_var_assign("EXTEN", exten))) {
+		AST_LIST_INSERT_HEAD(&headp, newvariable, entries);
+	}
+	if ((newvariable = ast_var_assign("CONTEXT", context))) {
+		AST_LIST_INSERT_HEAD(&headp, newvariable, entries);
+	}
+	if ((newvariable = ast_var_assign("PRIORITY", tmp))) {
+		AST_LIST_INSERT_HEAD(&headp, newvariable, entries);
+	}
 	/* Substitute variables */
 	pbx_substitute_variables_varshead(&headp, data, buf, buflen);
 	/* free the list */

Modified: trunk/utils/extconf.c
URL: http://svnview.digium.com/svn/asterisk/trunk/utils/extconf.c?view=diff&rev=396309&r1=396308&r2=396309
==============================================================================
--- trunk/utils/extconf.c (original)
+++ trunk/utils/extconf.c Tue Aug  6 03:36:15 2013
@@ -3164,10 +3164,9 @@
 		}
 	}
 
-	if (value) {
+	if (value && (newvariable = ast_var_assign(name, value))) {
 		if ((option_verbose > 1) && (headp == &globals))
 			ast_verbose(VERBOSE_PREFIX_2 "Setting global variable '%s' to '%s'\n", name, value);
-		newvariable = ast_var_assign(name, value);
 		AST_LIST_INSERT_HEAD(headp, newvariable, entries);
 	}
 




More information about the asterisk-commits mailing list