[asterisk-commits] res pjsip session: Check for removed stream state. (asterisk[master])

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Sep 21 12:30:18 CDT 2017


Joshua Colp has submitted this change and it was merged. ( https://gerrit.asterisk.org/6465 )

Change subject: res_pjsip_session: Check for removed stream state.
......................................................................

res_pjsip_session: Check for removed stream state.

When a sip session is refreshed, the stream topology is looped
through, checking each stream for compatible formats. This would
cause a crash if the stream state was AST_STREAM_STATE_REMOVED,
since the formats would never be set for this stream, causing
a NULL value to be returned from ast_stream_get_formats. This
commit adds a check for streams with removed states.

Also removed a stray semicolon.

Change-Id: Ic86f8b65a4a26a60885b28b8b1a0b22e1b471d42
---
M main/bridge.c
M res/res_pjsip_sdp_rtp.c
M res/res_pjsip_session.c
3 files changed, 8 insertions(+), 6 deletions(-)

Approvals:
  Richard Mudgett: Looks good to me, but someone else must approve
  Joshua Colp: Looks good to me, approved; Approved for Submit



diff --git a/main/bridge.c b/main/bridge.c
index ab12ecf..5d9c0c1 100644
--- a/main/bridge.c
+++ b/main/bridge.c
@@ -1741,7 +1741,7 @@
 
 	ao2_ref(bridge_channel, -1);
 
-join_exit:;
+join_exit:
 	ast_bridge_run_after_callback(chan);
 	bridge_channel_impart_signal(chan);
 	if (!(ast_channel_softhangup_internal_flag(chan) & AST_SOFTHANGUP_ASYNCGOTO)
diff --git a/res/res_pjsip_sdp_rtp.c b/res/res_pjsip_sdp_rtp.c
index e095f06..8ec57aa 100644
--- a/res/res_pjsip_sdp_rtp.c
+++ b/res/res_pjsip_sdp_rtp.c
@@ -1338,7 +1338,7 @@
 		media->desc.port = 0;
 		media->desc.port_count = 1;
 
-		if (remote) {
+		if (remote && remote->media[ast_stream_get_position(stream)]) {
 			pjmedia_sdp_media *remote_media = remote->media[ast_stream_get_position(stream)];
 			int index;
 
diff --git a/res/res_pjsip_session.c b/res/res_pjsip_session.c
index 64416a0..77ddfbc 100644
--- a/res/res_pjsip_session.c
+++ b/res/res_pjsip_session.c
@@ -1455,6 +1455,10 @@
 					continue;
 				}
 
+				/* No need to do anything with stream if it's media state is removed */
+				if (ast_stream_get_state(stream) == AST_STREAM_STATE_REMOVED) {
+					continue;
+				}
 
 				/* Enforce the configured allowed codecs on audio and video streams */
 				if (ast_stream_get_type(stream) == AST_MEDIA_TYPE_AUDIO || ast_stream_get_type(stream) == AST_MEDIA_TYPE_VIDEO) {
@@ -1465,14 +1469,12 @@
 						ast_sip_session_media_state_free(media_state);
 						return 0;
 					}
-
 					ast_format_cap_get_compatible(ast_stream_get_formats(stream), session->endpoint->media.codecs, joint_cap);
 					if (!ast_format_cap_count(joint_cap)) {
 						ao2_ref(joint_cap, -1);
-						ast_sip_session_media_state_free(media_state);
-						return 0;
+						ast_stream_set_state(stream, AST_STREAM_STATE_REMOVED);
+						continue;
 					}
-
 					ast_stream_set_formats(stream, joint_cap);
 				}
 

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

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Ic86f8b65a4a26a60885b28b8b1a0b22e1b471d42
Gerrit-Change-Number: 6465
Gerrit-PatchSet: 6
Gerrit-Owner: Benjamin Keith Ford <bford at digium.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Matthew Fredrickson <creslin at digium.com>
Gerrit-Reviewer: Richard Mudgett <rmudgett at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-commits/attachments/20170921/c8a39bad/attachment-0001.html>


More information about the asterisk-commits mailing list