[asterisk-commits] mjordan: branch 11 r392810 - in /branches/11: channels/ main/ res/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Jun 24 20:07:31 CDT 2013


Author: mjordan
Date: Mon Jun 24 20:07:29 2013
New Revision: 392810

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=392810
Log:
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)

Modified:
    branches/11/channels/chan_motif.c
    branches/11/main/config_options.c
    branches/11/main/http.c
    branches/11/main/named_acl.c
    branches/11/res/res_calendar.c

Modified: branches/11/channels/chan_motif.c
URL: http://svnview.digium.com/svn/asterisk/branches/11/channels/chan_motif.c?view=diff&rev=392810&r1=392809&r2=392810
==============================================================================
--- branches/11/channels/chan_motif.c (original)
+++ branches/11/channels/chan_motif.c Mon Jun 24 20:07:29 2013
@@ -2555,9 +2555,9 @@
 	aco_option_register_custom(&cfg_info, "connection", ACO_EXACT, endpoint_options, NULL, custom_connection_handler, 0);
 	aco_option_register_custom(&cfg_info, "transport", ACO_EXACT, endpoint_options, NULL, custom_transport_handler, 0);
 	aco_option_register(&cfg_info, "maxicecandidates", ACO_EXACT, endpoint_options, DEFAULT_MAX_ICE_CANDIDATES, OPT_UINT_T, PARSE_DEFAULT,
-			    FLDSET(struct jingle_endpoint, maxicecandidates));
+			    FLDSET(struct jingle_endpoint, maxicecandidates), DEFAULT_MAX_ICE_CANDIDATES);
 	aco_option_register(&cfg_info, "maxpayloads", ACO_EXACT, endpoint_options, DEFAULT_MAX_PAYLOADS, OPT_UINT_T, PARSE_DEFAULT,
-			    FLDSET(struct jingle_endpoint, maxpayloads));
+			    FLDSET(struct jingle_endpoint, maxpayloads), DEFAULT_MAX_PAYLOADS);
 
 	ast_format_cap_add_all_by_type(jingle_tech.capabilities, AST_FORMAT_TYPE_AUDIO);
 
@@ -2608,6 +2608,8 @@
 static int unload_module(void)
 {
 	ast_channel_unregister(&jingle_tech);
+	ast_format_cap_destroy(jingle_tech.capabilities);
+	jingle_tech.capabilities = NULL;
 	ast_rtp_glue_unregister(&jingle_rtp_glue);
 	ast_sched_context_destroy(sched);
 	aco_info_destroy(&cfg_info);

Modified: branches/11/main/config_options.c
URL: http://svnview.digium.com/svn/asterisk/branches/11/main/config_options.c?view=diff&rev=392810&r1=392809&r2=392810
==============================================================================
--- branches/11/main/config_options.c (original)
+++ branches/11/main/config_options.c Mon Jun 24 20:07:29 2013
@@ -153,14 +153,15 @@
 			return -1;
 		}
 		if (!ao2_link(type->internal->opts, opt)) {
-			while (--idx) {
+			do {
 				ao2_unlink(types[idx]->internal->opts, opt);
-			}
-			return -1;
-		}
-		/* The container should hold the only ref to opt */
-		ao2_ref(opt, -1);
-	}
+			} while (--idx);
+			return -1;
+		}
+	}
+	/* The container(s) should hold the only ref to opt */
+	ao2_ref(opt, -1);
+
 	return 0;
 }
 

Modified: branches/11/main/http.c
URL: http://svnview.digium.com/svn/asterisk/branches/11/main/http.c?view=diff&rev=392810&r1=392809&r2=392810
==============================================================================
--- branches/11/main/http.c (original)
+++ branches/11/main/http.c Mon Jun 24 20:07:29 2013
@@ -1024,7 +1024,7 @@
 	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;
 

Modified: branches/11/main/named_acl.c
URL: http://svnview.digium.com/svn/asterisk/branches/11/main/named_acl.c?view=diff&rev=392810&r1=392809&r2=392810
==============================================================================
--- branches/11/main/named_acl.c (original)
+++ branches/11/main/named_acl.c Mon Jun 24 20:07:29 2013
@@ -555,9 +555,17 @@
 	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;

Modified: branches/11/res/res_calendar.c
URL: http://svnview.digium.com/svn/asterisk/branches/11/res/res_calendar.c?view=diff&rev=392810&r1=392809&r2=392810
==============================================================================
--- branches/11/res/res_calendar.c (original)
+++ branches/11/res/res_calendar.c Mon Jun 24 20:07:29 2013
@@ -1810,6 +1810,8 @@
 
 	/* Remove all calendars */
 	ao2_callback(calendars, OBJ_UNLINK | OBJ_NODATA | OBJ_MULTIPLE, NULL, NULL);
+	ao2_cleanup(calendars);
+	calendars = NULL;
 
 	ast_mutex_lock(&refreshlock);
 	module_unloading = 1;




More information about the asterisk-commits mailing list