[asterisk-commits] mjordan: trunk r391521 - in /trunk: ./ main/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Jun 11 21:29:11 CDT 2013


Author: mjordan
Date: Tue Jun 11 21:29:08 2013
New Revision: 391521

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=391521
Log:
Fix memory leak while loading modules, adding formats, and destroying endpoints

This patch fixes three memory leaks
 * When we load a module with the LOAD_PRIORITY flag, we remove its entry from
   the load order list. Unfortunately, we don't free the memory associated with
   entry in the list. This patch corrects that and properly frees the memory
   for the module in the list.

 * When adding a custom format (such as SILK or CELT), the routine for adding
   the format was leaking a reference. RAII_VAR cleans this up properly.

 * We now de-ref the channel_snapshot appropriately when an endpoint is
   disposed of
........

Merged revisions 391489 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 391507 from http://svn.asterisk.org/svn/asterisk/branches/11

Modified:
    trunk/   (props changed)
    trunk/main/endpoints.c
    trunk/main/format.c
    trunk/main/loader.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-11-merged' - no diff available.

Modified: trunk/main/endpoints.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/endpoints.c?view=diff&rev=391521&r1=391520&r2=391521
==============================================================================
--- trunk/main/endpoints.c (original)
+++ trunk/main/endpoints.c Tue Jun 11 21:29:08 2013
@@ -116,6 +116,9 @@
 	ao2_cleanup(endpoint->topic);
 	endpoint->topic = NULL;
 
+	ao2_cleanup(endpoint->channel_ids);
+	endpoint->channel_ids = NULL;
+
 	ast_string_field_free_memory(endpoint);
 }
 
@@ -357,6 +360,7 @@
 		RAII_VAR(char *, channel_id, obj, ao2_cleanup);
 		snapshot->channel_ids[snapshot->num_channels++] = channel_id;
 	}
+	ao2_iterator_destroy(&i);
 
 	ao2_ref(snapshot, +1);
 	return snapshot;

Modified: trunk/main/format.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/format.c?view=diff&rev=391521&r1=391520&r2=391521
==============================================================================
--- trunk/main/format.c (original)
+++ trunk/main/format.c Tue Jun 11 21:29:08 2013
@@ -912,7 +912,7 @@
 
 static int format_list_add_custom(struct ast_format_list *new)
 {
-	struct ast_format_list *entry;
+	RAII_VAR(struct ast_format_list *, entry, NULL, ao2_cleanup);
 	if (!(entry = ao2_alloc(sizeof(*entry), NULL))) {
 		return -1;
 	}

Modified: trunk/main/loader.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/loader.c?view=diff&rev=391521&r1=391520&r2=391521
==============================================================================
--- trunk/main/loader.c (original)
+++ trunk/main/loader.c Tue Jun 11 21:29:08 2013
@@ -1110,6 +1110,8 @@
 			break;
 		case AST_MODULE_LOAD_PRIORITY:
 			AST_LIST_REMOVE_CURRENT(entry);
+			ast_free(order->resource);
+			ast_free(order);
 			break;
 		}
 	}




More information about the asterisk-commits mailing list