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
This commit is contained in:
Scott Griepentrog
2015-03-17 22:15:42 +00:00
parent f25b265329
commit 8c65c9167e
8 changed files with 67 additions and 50 deletions

View File

@@ -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;
}
}
}
}