[asterisk-commits] chan sip.c: Move NULL check to where it will do some good. (asterisk[11])

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Aug 3 08:42:10 CDT 2015


Joshua Colp has submitted this change and it was merged.

Change subject: chan_sip.c: Move NULL check to where it will do some good.
......................................................................


chan_sip.c: Move NULL check to where it will do some good.

v11 only fix.

Change-Id: I340512f86cfd3a6f7703971fa8acfffc7d47132b
---
M channels/chan_sip.c
1 file changed, 9 insertions(+), 5 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/channels/chan_sip.c b/channels/chan_sip.c
index 57430ac..58384af 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -12663,6 +12663,12 @@
 	struct ast_format_list fmt;
 	const char *mime;
 	unsigned int rate;
+	struct ast_codec_pref *pref;
+
+	if (!p->rtp) {
+		/* I don't see how you couldn't have p->rtp, but good to check for and error out if not there like earlier code */
+		return;
+	}
 
 	if (debug)
 		ast_verbose("Adding codec %u (%s) to SDP\n", format->id, ast_getformatname(format));
@@ -12673,11 +12679,9 @@
 		return;
 	}
 
-	if (p->rtp) {
-		struct ast_codec_pref *pref = &ast_rtp_instance_get_codecs(p->rtp)->pref;
-		fmt = ast_codec_pref_getsize(pref, format);
-	} else /* I don't see how you couldn't have p->rtp, but good to check for and error out if not there like earlier code */
-		return;
+	pref = &ast_rtp_instance_get_codecs(p->rtp)->pref;
+	fmt = ast_codec_pref_getsize(pref, format);
+
 	ast_str_append(m_buf, 0, " %d", rtp_code);
 	ast_str_append(a_buf, 0, "a=rtpmap:%d %s/%u\r\n", rtp_code, mime, rate);
 

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I340512f86cfd3a6f7703971fa8acfffc7d47132b
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-commits mailing list