[asterisk-commits] dvossel: branch dvossel/fixtheworld_phase1_step3 r304145 - in /team/dvossel/f...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Jan 26 11:31:50 CST 2011


Author: dvossel
Date: Wed Jan 26 11:31:45 2011
New Revision: 304145

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=304145
Log:
Addresses memory leaks found in using the ast_format_cap api

Modified:
    team/dvossel/fixtheworld_phase1_step3/channels/chan_local.c
    team/dvossel/fixtheworld_phase1_step3/channels/chan_sip.c
    team/dvossel/fixtheworld_phase1_step3/main/channel.c
    team/dvossel/fixtheworld_phase1_step3/main/dial.c
    team/dvossel/fixtheworld_phase1_step3/main/rtp_engine.c

Modified: team/dvossel/fixtheworld_phase1_step3/channels/chan_local.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/channels/chan_local.c?view=diff&rev=304145&r1=304144&r2=304145
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/channels/chan_local.c (original)
+++ team/dvossel/fixtheworld_phase1_step3/channels/chan_local.c Wed Jan 26 11:31:45 2011
@@ -953,13 +953,19 @@
 	return 0;
 }
 
+static void local_destroy(void *obj)
+{
+	struct local_pvt *pvt = obj;
+	pvt->reqcap = ast_format_cap_destroy(pvt->reqcap);
+}
+
 /*! \brief Create a call structure */
 static struct local_pvt *local_alloc(const char *data, struct ast_format_cap *cap)
 {
 	struct local_pvt *tmp = NULL;
 	char *c = NULL, *opts = NULL;
 
-	if (!(tmp = ao2_alloc(sizeof(*tmp), NULL))) {
+	if (!(tmp = ao2_alloc(sizeof(*tmp), local_destroy))) {
 		return NULL;
 	}
 	if (!(tmp->reqcap = ast_format_cap_dup(cap))) {

Modified: team/dvossel/fixtheworld_phase1_step3/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/channels/chan_sip.c?view=diff&rev=304145&r1=304144&r2=304145
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/channels/chan_sip.c (original)
+++ team/dvossel/fixtheworld_phase1_step3/channels/chan_sip.c Wed Jan 26 11:31:45 2011
@@ -10725,7 +10725,6 @@
 		goto add_sdp_cleanup;
 	}
 	if (!p->rtp) {
-		ast_format_cap_destroy(alreadysent);
 		ast_log(LOG_WARNING, "No way to add SDP without an RTP structure\n");
 		res = AST_FAILURE;
 		goto add_sdp_cleanup;

Modified: team/dvossel/fixtheworld_phase1_step3/main/channel.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/main/channel.c?view=diff&rev=304145&r1=304144&r2=304145
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/main/channel.c (original)
+++ team/dvossel/fixtheworld_phase1_step3/main/channel.c Wed Jan 26 11:31:45 2011
@@ -2430,6 +2430,8 @@
 		 */
 		ast_devstate_changed_literal(AST_DEVICE_UNKNOWN, device_name);
 	}
+
+	chan->nativeformats = ast_format_cap_destroy(chan->nativeformats);
 }
 
 /*! \brief Free a dummy channel structure */

Modified: team/dvossel/fixtheworld_phase1_step3/main/dial.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/main/dial.c?view=diff&rev=304145&r1=304144&r2=304145
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/main/dial.c (original)
+++ team/dvossel/fixtheworld_phase1_step3/main/dial.c Wed Jan 26 11:31:45 2011
@@ -267,6 +267,7 @@
 		cap_all_audio = ast_format_cap_destroy(cap_all_audio);
 		return -1;
 	}
+	cap_request = NULL;
 	cap_all_audio = ast_format_cap_destroy(cap_all_audio);
 
 	channel->owner->appl = "AppDial2";

Modified: team/dvossel/fixtheworld_phase1_step3/main/rtp_engine.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/main/rtp_engine.c?view=diff&rev=304145&r1=304144&r2=304145
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/main/rtp_engine.c (original)
+++ team/dvossel/fixtheworld_phase1_step3/main/rtp_engine.c Wed Jan 26 11:31:45 2011
@@ -1315,6 +1315,7 @@
 	int unlock_chans = 1;
 
 	if (!cap0 || !cap1) {
+		unlock_chans = 0;
 		goto done;
 	}
 
@@ -1556,6 +1557,8 @@
 
 	/* If there is no second channel just immediately bail out, we are of no use in that scenario */
 	if (!c1) {
+		ast_format_cap_destroy(cap0);
+		ast_format_cap_destroy(cap1);
 		return -1;
 	}
 




More information about the asterisk-commits mailing list