[Asterisk-code-review] res pjsip t38: Better error checking for t38 create media st... (asterisk[15])

Corey Farrell asteriskteam at digium.com
Tue Nov 7 11:36:48 CST 2017


Corey Farrell has uploaded this change for review. ( https://gerrit.asterisk.org/7102


Change subject: res_pjsip_t38: Better error checking for t38_create_media_state.
......................................................................

res_pjsip_t38: Better error checking for t38_create_media_state.

Change-Id: I81b2587427c6982aa3e2a3f9ad69cce8d316eb10
---
M res/res_pjsip_t38.c
1 file changed, 11 insertions(+), 2 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/02/7102/1

diff --git a/res/res_pjsip_t38.c b/res/res_pjsip_t38.c
index 48cbab3..8f1905f 100644
--- a/res/res_pjsip_t38.c
+++ b/res/res_pjsip_t38.c
@@ -363,7 +363,11 @@
 	}
 
 	ast_stream_set_state(stream, AST_STREAM_STATE_SENDRECV);
-	ast_stream_topology_set_stream(media_state->topology, 0, stream);
+	if (ast_stream_topology_set_stream(media_state->topology, 0, stream)) {
+		ast_stream_free(stream);
+		ast_sip_session_media_state_free(media_state);
+		return NULL;
+	}
 
 	caps = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT);
 	if (!caps) {
@@ -371,9 +375,14 @@
 		return NULL;
 	}
 
-	ast_format_cap_append(caps, ast_format_t38, 0);
 	ast_stream_set_formats(stream, caps);
+	/* stream holds a reference to cap, release the local reference
+	 * now so we don't have to deal with it in the error condition. */
 	ao2_ref(caps, -1);
+	if (ast_format_cap_append(caps, ast_format_t38, 0)) {
+		ast_sip_session_media_state_free(media_state);
+		return NULL;
+	}
 
 	session_media = ast_sip_session_media_state_add(session, media_state, AST_MEDIA_TYPE_IMAGE, 0);
 	if (!session_media) {

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

Gerrit-Project: asterisk
Gerrit-Branch: 15
Gerrit-MessageType: newchange
Gerrit-Change-Id: I81b2587427c6982aa3e2a3f9ad69cce8d316eb10
Gerrit-Change-Number: 7102
Gerrit-PatchSet: 1
Gerrit-Owner: Corey Farrell <git at cfware.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20171107/132f4589/attachment.html>


More information about the asterisk-code-review mailing list