[Asterisk-code-review] rtp engine.c: Fix off nominal ref leak and some minor tweaks. (asterisk[11])

Joshua Colp asteriskteam at digium.com
Mon Aug 3 08:42:10 CDT 2015


Joshua Colp has submitted this change and it was merged.

Change subject: rtp_engine.c: Fix off nominal ref leak and some minor tweaks.
......................................................................


rtp_engine.c: Fix off nominal ref leak and some minor tweaks.

v11 only fix.

Change-Id: I97885946ebc7eda19f1c18d08698117cf6a7f14f
---
M main/rtp_engine.c
1 file changed, 5 insertions(+), 7 deletions(-)

Approvals:
  Mark Michelson: Looks good to me, but someone else must approve
  Anonymous Coward #1000019: Verified
  Joshua Colp: Looks good to me, approved



diff --git a/main/rtp_engine.c b/main/rtp_engine.c
index ac349e8..944c477 100644
--- a/main/rtp_engine.c
+++ b/main/rtp_engine.c
@@ -512,16 +512,15 @@
 		new_type = ao2_find(dest->payloads, &i, OBJ_KEY | OBJ_NOLOCK);
 		if (!new_type) {
 			new_type = ao2_alloc(sizeof(*new_type), NULL);
+			if (!new_type) {
+				ao2_ref(type, -1);
+				continue;
+			}
 			payload_alloced = 1;
-		}
-
-		if (!new_type) {
-			continue;
 		}
 
 		ast_debug(2, "Copying payload %d from %p to %p\n", i, src, dest);
 
-		new_type->payload = i;
 		*new_type = *type;
 
 		if (payload_alloced) {
@@ -560,7 +559,6 @@
 
 	type->asterisk_format = static_RTP_PT[payload].asterisk_format;
 	type->rtp_code = static_RTP_PT[payload].rtp_code;
-	type->payload = payload;
 	ast_format_copy(&type->format, &static_RTP_PT[payload].format);
 
 	ast_debug(1, "Setting payload %d based on m type on %p\n", payload, codecs);
@@ -610,7 +608,7 @@
 
 		if (!(type = ao2_find(codecs->payloads, &pt, OBJ_KEY | OBJ_NOLOCK))) {
 			if (!(type = ao2_alloc(sizeof(*type), NULL))) {
-				continue;
+				break;
 			}
 			type->payload = pt;
 			ao2_link_flags(codecs->payloads, type, OBJ_NOLOCK);

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I97885946ebc7eda19f1c18d08698117cf6a7f14f
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: 11
Gerrit-Owner: Richard Mudgett <rmudgett at digium.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Mark Michelson <mmichelson at digium.com>



More information about the asterisk-code-review mailing list