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


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@396309 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Walter Doekes
2013-08-06 08:36:15 +00:00
parent c0f302e1e1
commit ccdfe67bf2
9 changed files with 48 additions and 33 deletions

View File

@@ -607,14 +607,18 @@ static int dundi_lookup_local(struct dundi_result *dr, struct dundi_mapping *map
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)))