[asterisk-commits] mjordan: trunk r391479 - in /trunk: bridges/ main/

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


Author: mjordan
Date: Tue Jun 11 21:13:31 2013
New Revision: 391479

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=391479
Log:
Fix memory leaks in stasis_channels and bridge_native_rtp

This patch fixes two memory leaks:
 * A memory leak in packing channels into a multi-channel blob payload when
   publishing dial messages. The multi-channel blob payload does not steal
   the references - this approach was chosen because it works well with the
   RAII_VAR macro. Unfortunately, this does mean that you actually have to use
   the RAII_VAR macro (or manually deref it yourself)
 * RTP instances returned as a result of one of the glue operations are ref
   counted and have to be de-ref'd appropriately. We now do that, as saying
   that we should do it and then not would be silly.



Modified:
    trunk/bridges/bridge_native_rtp.c
    trunk/main/stasis_channels.c

Modified: trunk/bridges/bridge_native_rtp.c
URL: http://svnview.digium.com/svn/asterisk/trunk/bridges/bridge_native_rtp.c?view=diff&rev=391479&r1=391478&r2=391479
==============================================================================
--- trunk/bridges/bridge_native_rtp.c (original)
+++ trunk/bridges/bridge_native_rtp.c Tue Jun 11 21:13:31 2013
@@ -155,7 +155,10 @@
 	struct ast_bridge_channel *c1 = AST_LIST_LAST(&bridge->channels);
 	enum ast_rtp_glue_result native_type;
 	struct ast_rtp_glue *glue0, *glue1;
-	struct ast_rtp_instance *instance0 = NULL, *instance1 = NULL, *vinstance0 = NULL, *vinstance1 = NULL;
+	RAII_VAR(struct ast_rtp_instance *, instance0, NULL, ao2_cleanup);
+	RAII_VAR(struct ast_rtp_instance *, instance1, NULL, ao2_cleanup);
+	RAII_VAR(struct ast_rtp_instance *, vinstance0, NULL, ao2_cleanup);
+	RAII_VAR(struct ast_rtp_instance *, vinstance1, NULL, ao2_cleanup);
 	RAII_VAR(struct ast_format_cap *, cap0, ast_format_cap_alloc_nolock(), ast_format_cap_destroy);
 	RAII_VAR(struct ast_format_cap *, cap1, ast_format_cap_alloc_nolock(), ast_format_cap_destroy);
 	int read_ptime0, read_ptime1, write_ptime0, write_ptime1;

Modified: trunk/main/stasis_channels.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/stasis_channels.c?view=diff&rev=391479&r1=391478&r2=391479
==============================================================================
--- trunk/main/stasis_channels.c (original)
+++ trunk/main/stasis_channels.c Tue Jun 11 21:13:31 2013
@@ -120,6 +120,7 @@
 {
 	struct ast_channel_snapshot *snapshot = obj;
 	ast_string_field_free_memory(snapshot);
+	ao2_cleanup(snapshot->manager_vars);
 }
 
 struct ast_channel_snapshot *ast_channel_snapshot_create(struct ast_channel *chan)
@@ -199,8 +200,8 @@
 	RAII_VAR(struct ast_multi_channel_blob *, payload, NULL, ao2_cleanup);
 	RAII_VAR(struct stasis_message *, msg, NULL, ao2_cleanup);
 	RAII_VAR(struct ast_json *, blob, NULL, ast_json_unref);
-	struct ast_channel_snapshot *caller_snapshot;
-	struct ast_channel_snapshot *peer_snapshot;
+	RAII_VAR(struct ast_channel_snapshot *, caller_snapshot, NULL, ao2_cleanup);
+	RAII_VAR(struct ast_channel_snapshot *, peer_snapshot, NULL, ao2_cleanup);
 
 	ast_assert(peer != NULL);
 	blob = ast_json_pack("{s: s, s: s}",




More information about the asterisk-commits mailing list