[asterisk-commits] wdoekes: branch 11 r396287 - in /branches/11: ./ apps/ funcs/ main/ pbx/ utils/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Aug 6 03:19:51 CDT 2013
Author: wdoekes
Date: Tue Aug 6 03:19:42 2013
New Revision: 396287
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=396287
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
Modified:
branches/11/ (props changed)
branches/11/apps/app_playback.c
branches/11/apps/app_stack.c
branches/11/funcs/func_global.c
branches/11/funcs/func_strings.c
branches/11/main/cdr.c
branches/11/main/pbx.c
branches/11/pbx/pbx_dundi.c
branches/11/pbx/pbx_loopback.c
branches/11/utils/extconf.c
Propchange: branches/11/
------------------------------------------------------------------------------
Binary property 'branch-1.8-merged' - no diff available.
Modified: branches/11/apps/app_playback.c
URL: http://svnview.digium.com/svn/asterisk/branches/11/apps/app_playback.c?view=diff&rev=396287&r1=396286&r2=396287
==============================================================================
--- branches/11/apps/app_playback.c (original)
+++ branches/11/apps/app_playback.c Tue Aug 6 03:19:42 2013
@@ -212,6 +212,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: branches/11/apps/app_stack.c
URL: http://svnview.digium.com/svn/asterisk/branches/11/apps/app_stack.c?view=diff&rev=396287&r1=396286&r2=396287
==============================================================================
--- branches/11/apps/app_stack.c (original)
+++ branches/11/apps/app_stack.c Tue Aug 6 03:19:42 2013
@@ -245,8 +245,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: branches/11/funcs/func_global.c
URL: http://svnview.digium.com/svn/asterisk/branches/11/funcs/func_global.c?view=diff&rev=396287&r1=396286&r2=396287
==============================================================================
--- branches/11/funcs/func_global.c (original)
+++ branches/11/funcs/func_global.c Tue Aug 6 03:19:42 2013
@@ -253,15 +253,16 @@
}
AST_LIST_TRAVERSE_SAFE_END;
- var = ast_var_assign(args.var, S_OR(value, ""));
- AST_LIST_INSERT_HEAD(varshead, var, entries);
- manager_event(EVENT_FLAG_DIALPLAN, "VarSet",
- "Channel: %s\r\n"
- "Variable: SHARED(%s)\r\n"
- "Value: %s\r\n"
- "Uniqueid: %s\r\n",
- chan ? ast_channel_name(chan) : "none", args.var, value,
- chan ? ast_channel_uniqueid(chan) : "none");
+ if ((var = ast_var_assign(args.var, S_OR(value, "")))) {
+ AST_LIST_INSERT_HEAD(varshead, var, entries);
+ manager_event(EVENT_FLAG_DIALPLAN, "VarSet",
+ "Channel: %s\r\n"
+ "Variable: SHARED(%s)\r\n"
+ "Value: %s\r\n"
+ "Uniqueid: %s\r\n",
+ chan ? ast_channel_name(chan) : "none", args.var, value,
+ chan ? ast_channel_uniqueid(chan) : "none");
+ }
ast_channel_unlock(chan);
Modified: branches/11/funcs/func_strings.c
URL: http://svnview.digium.com/svn/asterisk/branches/11/funcs/func_strings.c?view=diff&rev=396287&r1=396286&r2=396287
==============================================================================
--- branches/11/funcs/func_strings.c (original)
+++ branches/11/funcs/func_strings.c Tue Aug 6 03:19:42 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: branches/11/main/cdr.c
URL: http://svnview.digium.com/svn/asterisk/branches/11/main/cdr.c?view=diff&rev=396287&r1=396286&r2=396287
==============================================================================
--- branches/11/main/cdr.c (original)
+++ branches/11/main/cdr.c Tue Aug 6 03:19:42 2013
@@ -383,8 +383,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);
}
}
@@ -408,8 +407,8 @@
AST_LIST_TRAVERSE(headpa,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(headpb, newvariable, entries);
x++;
}
Modified: branches/11/main/pbx.c
URL: http://svnview.digium.com/svn/asterisk/branches/11/main/pbx.c?view=diff&rev=396287&r1=396286&r2=396287
==============================================================================
--- branches/11/main/pbx.c (original)
+++ branches/11/main/pbx.c Tue Aug 6 03:19:42 2013
@@ -11332,10 +11332,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);
}
@@ -11382,10 +11381,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);
/*** DOCUMENTATION
<managerEventInstance>
Modified: branches/11/pbx/pbx_dundi.c
URL: http://svnview.digium.com/svn/asterisk/branches/11/pbx/pbx_dundi.c?view=diff&rev=396287&r1=396286&r2=396287
==============================================================================
--- branches/11/pbx/pbx_dundi.c (original)
+++ branches/11/pbx/pbx_dundi.c Tue Aug 6 03:19:42 2013
@@ -598,14 +598,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: branches/11/pbx/pbx_loopback.c
URL: http://svnview.digium.com/svn/asterisk/branches/11/pbx/pbx_loopback.c?view=diff&rev=396287&r1=396286&r2=396287
==============================================================================
--- branches/11/pbx/pbx_loopback.c (original)
+++ branches/11/pbx/pbx_loopback.c Tue Aug 6 03:19:42 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: branches/11/utils/extconf.c
URL: http://svnview.digium.com/svn/asterisk/branches/11/utils/extconf.c?view=diff&rev=396287&r1=396286&r2=396287
==============================================================================
--- branches/11/utils/extconf.c (original)
+++ branches/11/utils/extconf.c Tue Aug 6 03:19:42 2013
@@ -3149,10 +3149,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