mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-20 00:30:20 +00:00
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:
13
main/cdr.c
13
main/cdr.c
@@ -699,8 +699,8 @@ static int copy_variables(struct varshead *to_list, struct varshead *from_list)
|
||||
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 @@ static void set_variable(struct varshead *headp, const char *name, const char *v
|
||||
}
|
||||
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 @@ static struct ast_cdr *cdr_object_create_public_records(struct cdr_object *cdr)
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user