diff options
author | Scott Griepentrog <sgriepentrog@digium.com> | 2015-03-17 22:15:42 +0000 |
---|---|---|
committer | Scott Griepentrog <sgriepentrog@digium.com> | 2015-03-17 22:15:42 +0000 |
commit | 8c65c9167ee6fe75c7e7f511d12480831f98dad3 (patch) | |
tree | 5cde1e58b672d19b1ca5cdc2c9ad6f128bddf37b /main/config.c | |
parent | f25b2653293d0d96479d3d83795f40828f0b7bb7 (diff) |
Various: bugfixes found via chaos
Using DEBUG_CHAOS several instances of a null
pointer crash, and one uninitialized variable
were uncovered and fixed. Also added details
on why Asterisk failed to initialize.
Review: https://reviewboard.asterisk.org/r/4468/
........
Merged revisions 433064 from http://svn.asterisk.org/svn/asterisk/branches/13
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@433065 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/config.c')
-rw-r--r-- | main/config.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/main/config.c b/main/config.c index 7e5141398..517b33bfd 100644 --- a/main/config.c +++ b/main/config.c @@ -1238,23 +1238,27 @@ void ast_category_rename(struct ast_category *cat, const char *name) ast_copy_string(cat->name, name, sizeof(cat->name)); } -void ast_category_inherit(struct ast_category *new, const struct ast_category *base) +int ast_category_inherit(struct ast_category *new, const struct ast_category *base) { struct ast_variable *var; struct ast_category_template_instance *x; x = ast_calloc(1, sizeof(*x)); if (!x) { - return; + return -1; } strcpy(x->name, base->name); x->inst = base; AST_LIST_INSERT_TAIL(&new->template_instances, x, next); for (var = base->root; var; var = var->next) { struct ast_variable *cloned = variable_clone(var); + if (!cloned) { + return -1; + } cloned->inherited = 1; ast_variable_append(new, cloned); } + return 0; } struct ast_config *ast_config_new(void) @@ -1691,7 +1695,10 @@ static int process_text_line(struct ast_config *cfg, struct ast_category **cat, ast_log(LOG_WARNING, "Inheritance requested, but category '%s' does not exist, line %d of %s\n", cur, lineno, configfile); return -1; } - ast_category_inherit(*cat, base); + if (ast_category_inherit(*cat, base)) { + ast_log(LOG_ERROR, "Inheritence requested, but allocation failed\n"); + return -1; + } } } } |