Fix memory/ref counting leaks in a variety of locations

This patch fixes the following memory leaks:
 * http.c: The structure containing the addresses to bind to was not being
   deallocated when no longer used
 * named_acl.c: The global configuration information was not disposed of
 * config_options.c: An invalid read was occurring for certain option types.
 * res_calendar.c: The loaded calendars on module unload were not being
   properly disposed of.
 * chan_motif.c: The format capabilities needed to be disposed of on module
   unload. In addition, this now specifies the default options for the
   maxpayloads and maxicecandidates in such a way that it doesn't cause the
   invalid read in config_options.c to occur.

(issue ASTERISK-21906)
Reported by: John Hardin
patches:
  http.patch uploaded by jhardin (license 6512)
  named_acl.patch uploaded by jhardin (license 6512)
  config_options.patch uploaded by jhardin (license 6512)
  res_calendar.patch uploaded by jhardin (license 6512)
  chan_motif.patch uploaded by jhardin (license 6512)


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/11@392810 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Matthew Jordan
2013-06-25 01:07:29 +00:00
parent be6c8d267c
commit 2ffb648a20
5 changed files with 20 additions and 7 deletions

View File

@@ -153,14 +153,15 @@ static int link_option_to_types(struct aco_type **types, struct aco_option *opt)
return -1;
}
if (!ao2_link(type->internal->opts, opt)) {
while (--idx) {
do {
ao2_unlink(types[idx]->internal->opts, opt);
}
} while (--idx);
return -1;
}
/* The container should hold the only ref to opt */
ao2_ref(opt, -1);
}
/* The container(s) should hold the only ref to opt */
ao2_ref(opt, -1);
return 0;
}

View File

@@ -1024,7 +1024,7 @@ static int __ast_http_load(int reload)
struct http_uri_redirect *redirect;
struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
uint32_t bindport = DEFAULT_PORT;
struct ast_sockaddr *addrs = NULL;
RAII_VAR(struct ast_sockaddr *, addrs, NULL, ast_free);
int num_addrs = 0;
int http_tls_was_enabled = 0;

View File

@@ -555,10 +555,18 @@ static struct ast_cli_entry cli_named_acl[] = {
AST_CLI_DEFINE(handle_show_named_acl_cmd, "Show a named ACL or list all named ACLs"),
};
static void named_acl_cleanup(void)
{
aco_info_destroy(&cfg_info);
ao2_global_obj_release(globals);
}
int ast_named_acl_init()
{
ast_cli_register_multiple(cli_named_acl, ARRAY_LEN(cli_named_acl));
ast_register_atexit(named_acl_cleanup);
if (aco_info_init(&cfg_info)) {
return 0;
}