<p>Joshua Colp <strong>merged</strong> this change.</p><p><a href="https://gerrit.asterisk.org/6464">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  Richard Mudgett: Looks good to me, but someone else must approve
  Joshua Colp: Looks good to me, approved; Approved for Submit

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">res_pjsip_session: Check for removed stream state.<br><br>When a sip session is refreshed, the stream topology is looped<br>through, checking each stream for compatible formats. This would<br>cause a crash if the stream state was AST_STREAM_STATE_REMOVED,<br>since the formats would never be set for this stream, causing<br>a NULL value to be returned from ast_stream_get_formats. This<br>commit adds a check for streams with removed states.<br><br>Also removed a stray semicolon.<br><br>Change-Id: Ic86f8b65a4a26a60885b28b8b1a0b22e1b471d42<br>---<br>M main/bridge.c<br>M res/res_pjsip_sdp_rtp.c<br>M res/res_pjsip_session.c<br>3 files changed, 8 insertions(+), 6 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/main/bridge.c b/main/bridge.c<br>index ab12ecf..5d9c0c1 100644<br>--- a/main/bridge.c<br>+++ b/main/bridge.c<br>@@ -1741,7 +1741,7 @@<br> <br>     ao2_ref(bridge_channel, -1);<br> <br>-join_exit:;<br>+join_exit:<br>    ast_bridge_run_after_callback(chan);<br>  bridge_channel_impart_signal(chan);<br>   if (!(ast_channel_softhangup_internal_flag(chan) & AST_SOFTHANGUP_ASYNCGOTO)<br>diff --git a/res/res_pjsip_sdp_rtp.c b/res/res_pjsip_sdp_rtp.c<br>index 9110a1c..36dda87 100644<br>--- a/res/res_pjsip_sdp_rtp.c<br>+++ b/res/res_pjsip_sdp_rtp.c<br>@@ -1338,7 +1338,7 @@<br>          media->desc.port = 0;<br>              media->desc.port_count = 1;<br> <br>-            if (remote) {<br>+                if (remote && remote->media[ast_stream_get_position(stream)]) {<br>                    pjmedia_sdp_media *remote_media = remote->media[ast_stream_get_position(stream)];<br>                  int index;<br> <br>diff --git a/res/res_pjsip_session.c b/res/res_pjsip_session.c<br>index b997024..c3f929e 100644<br>--- a/res/res_pjsip_session.c<br>+++ b/res/res_pjsip_session.c<br>@@ -1455,6 +1455,10 @@<br>                                    continue;<br>                             }<br> <br>+                         /* No need to do anything with stream if it's media state is removed */<br>+                          if (ast_stream_get_state(stream) == AST_STREAM_STATE_REMOVED) {<br>+                                      continue;<br>+                            }<br> <br>                          /* Enforce the configured allowed codecs on audio and video streams */<br>                                if (ast_stream_get_type(stream) == AST_MEDIA_TYPE_AUDIO || ast_stream_get_type(stream) == AST_MEDIA_TYPE_VIDEO) {<br>@@ -1465,14 +1469,12 @@<br>                                            ast_sip_session_media_state_free(media_state);<br>                                                return 0;<br>                                     }<br>-<br>                                  ast_format_cap_get_compatible(ast_stream_get_formats(stream), session->endpoint->media.codecs, joint_cap);<br>                                      if (!ast_format_cap_count(joint_cap)) {<br>                                               ao2_ref(joint_cap, -1);<br>-                                              ast_sip_session_media_state_free(media_state);<br>-                                               return 0;<br>+                                            ast_stream_set_state(stream, AST_STREAM_STATE_REMOVED);<br>+                                              continue;<br>                                     }<br>-<br>                                  ast_stream_set_formats(stream, joint_cap);<br>                            }<br> <br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/6464">change 6464</a>. To unsubscribe, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/6464"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 15 </div>
<div style="display:none"> Gerrit-MessageType: merged </div>
<div style="display:none"> Gerrit-Change-Id: Ic86f8b65a4a26a60885b28b8b1a0b22e1b471d42 </div>
<div style="display:none"> Gerrit-Change-Number: 6464 </div>
<div style="display:none"> Gerrit-PatchSet: 6 </div>
<div style="display:none"> Gerrit-Owner: Benjamin Keith Ford <bford@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins2 </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Matthew Fredrickson <creslin@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Richard Mudgett <rmudgett@digium.com> </div>