[Asterisk-code-review] channel: Fix leak on successful call to chan->tech->requester. (asterisk[master])

Jenkins2 asteriskteam at digium.com
Mon Aug 7 09:30:22 CDT 2017


Jenkins2 has submitted this change and it was merged. ( https://gerrit.asterisk.org/6169 )

Change subject: channel: Fix leak on successful call to chan->tech->requester.
......................................................................

channel: Fix leak on successful call to chan->tech->requester.

joint_cap needs to be released unconditionally as chan->tech->requester
does not steal the reference even on success.

ASTERISK-27180 #close

Change-Id: I647728992559bdb0a9c7357c20be1b36400d68b6
---
M main/channel.c
1 file changed, 4 insertions(+), 9 deletions(-)

Approvals:
  Joshua Colp: Looks good to me, but someone else must approve
  George Joseph: Looks good to me, approved
  Jenkins2: Approved for Submit



diff --git a/main/channel.c b/main/channel.c
index 6682555..632d472 100644
--- a/main/channel.c
+++ b/main/channel.c
@@ -6022,7 +6022,7 @@
 	const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *addr, int *cause)
 {
 	struct chanlist *chan;
-	struct ast_channel *c;
+	struct ast_channel *c = NULL;
 	int res;
 	int foo;
 
@@ -6063,9 +6063,6 @@
 		c = chan->tech->requester_with_stream_topology(type, topology, assignedids, requestor, addr, cause);
 
 		ast_stream_topology_free(tmp_converted_topology);
-		if (!c) {
-			return NULL;
-		}
 	} else if (chan->tech->requester) {
 		struct ast_format_cap *tmp_converted_cap = NULL;
 		struct ast_format_cap *tmp_cap;
@@ -6116,12 +6113,10 @@
 		ao2_cleanup(tmp_converted_cap);
 
 		c = chan->tech->requester(type, joint_cap, assignedids, requestor, addr, cause);
+		ao2_ref(joint_cap, -1);
+	}
 
-		if (!c) {
-			ao2_ref(joint_cap, -1);
-			return NULL;
-		}
-	} else {
+	if (!c) {
 		return NULL;
 	}
 

-- 
To view, visit https://gerrit.asterisk.org/6169
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I647728992559bdb0a9c7357c20be1b36400d68b6
Gerrit-Change-Number: 6169
Gerrit-PatchSet: 2
Gerrit-Owner: Corey Farrell <git at cfware.com>
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20170807/5934d56f/attachment.html>


More information about the asterisk-code-review mailing list