[asterisk-commits] rmudgett: trunk r364846 - in /trunk: ./ channels/chan_local.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue May 1 17:00:15 CDT 2012


Author: rmudgett
Date: Tue May  1 17:00:11 2012
New Revision: 364846

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=364846
Log:
* Fix error path resouce leak in local_request().

* Restructure local_request() to reduce indentation.
........

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

Merged revisions 364845 from http://svn.asterisk.org/svn/asterisk/branches/10

Modified:
    trunk/   (props changed)
    trunk/channels/chan_local.c

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

Modified: trunk/channels/chan_local.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_local.c?view=diff&rev=364846&r1=364845&r2=364846
==============================================================================
--- trunk/channels/chan_local.c (original)
+++ trunk/channels/chan_local.c Tue May  1 17:00:11 2012
@@ -1176,20 +1176,26 @@
 /*! \brief Part of PBX interface */
 static struct ast_channel *local_request(const char *type, struct ast_format_cap *cap, const struct ast_channel *requestor, const char *data, int *cause)
 {
-	struct local_pvt *p = NULL;
-	struct ast_channel *chan = NULL;
+	struct local_pvt *p;
+	struct ast_channel *chan;
 
 	/* Allocate a new private structure and then Asterisk channel */
-	if ((p = local_alloc(data, cap))) {
-		if (!(chan = local_new(p, AST_STATE_DOWN, requestor ? ast_channel_linkedid(requestor) : NULL))) {
-			ao2_unlink(locals, p);
-		}
-		if (chan && ast_channel_cc_params_init(chan, requestor ? ast_channel_get_cc_config_params((struct ast_channel *)requestor) : NULL)) {
-			chan = ast_channel_release(chan);
-			ao2_unlink(locals, p);
-		}
-		ao2_ref(p, -1); /* kill the ref from the alloc */
-	}
+	p = local_alloc(data, cap);
+	if (!p) {
+		return NULL;
+	}
+	chan = local_new(p, AST_STATE_DOWN, requestor ? ast_channel_linkedid(requestor) : NULL);
+	if (!chan) {
+		ao2_unlink(locals, p);
+	} else if (ast_channel_cc_params_init(chan, requestor ? ast_channel_get_cc_config_params((struct ast_channel *)requestor) : NULL)) {
+		ao2_unlink(locals, p);
+		p->owner = ast_channel_release(p->owner);
+		ast_module_user_remove(p->u_owner);
+		p->chan = ast_channel_release(p->chan);
+		ast_module_user_remove(p->u_chan);
+		chan = NULL;
+	}
+	ao2_ref(p, -1); /* kill the ref from the alloc */
 
 	return chan;
 }




More information about the asterisk-commits mailing list