<p>Friendly Automation <strong>submitted</strong> this change.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/14713">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  Joshua Colp: Looks good to me, but someone else must approve
  Kevin Harwell: Looks good to me, approved
  Friendly Automation: Approved for Submit

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">res_pjsip_session: Ensure reused streams have correct bundle group<br><br>When a bundled stream is removed, its bundle_group is reset to -1.<br>If that stream is later reused, the bundle parameters on session<br>media need to be reset correctly it could mistakenly be rebundled<br>with a stream that was removed and never reused.  Since the removed<br>stream has no rtp instance, a crash will result.<br><br>Change-Id: Ie2b792220f9291587ab5f9fd123145559dba96d7<br>---<br>M res/res_pjsip_session.c<br>1 file changed, 14 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/res/res_pjsip_session.c b/res/res_pjsip_session.c</span><br><span>index f34f7c9..ab558f6 100644</span><br><span>--- a/res/res_pjsip_session.c</span><br><span>+++ b/res/res_pjsip_session.c</span><br><span>@@ -487,6 +487,20 @@</span><br><span>              /* A stream can never exist without an accompanying media session */</span><br><span>                 if (session_media->type == type) {</span><br><span>                        ao2_ref(session_media, +1);</span><br><span style="color: hsl(120, 100%, 40%);">+                   /*</span><br><span style="color: hsl(120, 100%, 40%);">+                     * If this session_media was previously removed, its bundle group was probably reset</span><br><span style="color: hsl(120, 100%, 40%);">+                   * to -1 so if bundling is enabled on the endpoint, we need to reset it to 0, set</span><br><span style="color: hsl(120, 100%, 40%);">+                      * the bundled flag and reset its mid.</span><br><span style="color: hsl(120, 100%, 40%);">+                         */</span><br><span style="color: hsl(120, 100%, 40%);">+                   if (session->endpoint->media.bundle && session_media->bundle_group == -1) {</span><br><span style="color: hsl(120, 100%, 40%);">+                          session_media->bundled = session->endpoint->media.webrtc;</span><br><span style="color: hsl(120, 100%, 40%);">+                            session_media->bundle_group = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+                           ast_free(session_media->mid);</span><br><span style="color: hsl(120, 100%, 40%);">+                              if (ast_asprintf(&session_media->mid, "%s-%d", ast_codec_media_type2str(type), position) < 0) {</span><br><span style="color: hsl(120, 100%, 40%);">+                                   ao2_ref(session_media, -1);</span><br><span style="color: hsl(120, 100%, 40%);">+                                   return NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+                          }</span><br><span style="color: hsl(120, 100%, 40%);">+                     }</span><br><span>            } else {</span><br><span>                     session_media = NULL;</span><br><span>                }</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/14713">change 14713</a>. To unsubscribe, or for help writing mail filters, 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/c/asterisk/+/14713"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 16 </div>
<div style="display:none"> Gerrit-Change-Id: Ie2b792220f9291587ab5f9fd123145559dba96d7 </div>
<div style="display:none"> Gerrit-Change-Number: 14713 </div>
<div style="display:none"> Gerrit-PatchSet: 2 </div>
<div style="display:none"> Gerrit-Owner: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Friendly Automation </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@sangoma.com> </div>
<div style="display:none"> Gerrit-Reviewer: Kevin Harwell <kharwell@digium.com> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>