diff options
author | Scott Griepentrog <sgriepentrog@digium.com> | 2015-03-17 22:15:09 +0000 |
---|---|---|
committer | Scott Griepentrog <sgriepentrog@digium.com> | 2015-03-17 22:15:09 +0000 |
commit | 2c7b9451499c5bd50bc6fa54a0073781b116834c (patch) | |
tree | 66390386d5b9e4200c83afa3448bd4d054254349 /main/config.c | |
parent | 1fb1c81923249413e3e439a645ade8793ccc0db6 (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/
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/13@433064 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; + } } } } |