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

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">res_pjsip_session: Make reschedule_reinvite check for NULL topologies<br><br>When the check for equal topologies was added to reschedule_reinvite()<br>it was assumed that both the pending and active media states would<br>actually have non-NULL topologies.  We since discovered this isn't<br>the case.<br><br>We now only test for equal topologies if both media states have<br>non-NULL topologies.  The logic had to be rearranged a bit to make<br>sure that we cloned the media states if their topologies were<br>non-NULL but weren't equal.<br><br>ASTERISK-29215<br><br>Change-Id: I61313cca7fc571144338aac826091791b87b6e17<br>---<br>M res/res_pjsip_session.c<br>1 file changed, 25 insertions(+), 3 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 e319842..3f61b63 100644</span><br><span>--- a/res/res_pjsip_session.c</span><br><span>+++ b/res/res_pjsip_session.c</span><br><span>@@ -4273,18 +4273,40 @@</span><br><span>        struct ast_sip_session_media_state *pending_media_state = NULL;</span><br><span>      struct ast_sip_session_media_state *active_media_state = NULL;</span><br><span>       const char *session_name = ast_sip_session_get_name(session);</span><br><span style="color: hsl(120, 100%, 40%);">+ int use_pending = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+  int use_active = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>        SCOPE_ENTER(3, "%s\n", session_name);</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-     /* If the two media state topologies are the same this means that the session refresh request</span><br><span style="color: hsl(120, 100%, 40%);">+ /*</span><br><span style="color: hsl(120, 100%, 40%);">+     * If the two media state topologies are the same this means that the session refresh request</span><br><span>         * did not specify a desired topology, so it does not care. If that is the case we don't even</span><br><span style="color: hsl(0, 100%, 40%);">-        * pass one in here resulting in the current topology being used.</span><br><span style="color: hsl(120, 100%, 40%);">+      * pass one in here resulting in the current topology being used.  It's possible though that</span><br><span style="color: hsl(120, 100%, 40%);">+       * either one of the topologies could be NULL so we have to test for that before we check for</span><br><span style="color: hsl(120, 100%, 40%);">+  * equality.</span><br><span>          */</span><br><span style="color: hsl(0, 100%, 40%);">-     if (!ast_stream_topology_equal(session->active_media_state->topology, session->pending_media_state->topology)) {</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+        /* We only want to clone a media state if its topology is not null */</span><br><span style="color: hsl(120, 100%, 40%);">+ use_pending = session->pending_media_state->topology != NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+   use_active = session->active_media_state->topology != NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   /*</span><br><span style="color: hsl(120, 100%, 40%);">+     * If both media states have topologies, we can test for equality.  If they're equal we're not going to</span><br><span style="color: hsl(120, 100%, 40%);">+        * clone either states.</span><br><span style="color: hsl(120, 100%, 40%);">+        */</span><br><span style="color: hsl(120, 100%, 40%);">+   if (use_pending && use_active && ast_stream_topology_equal(session->active_media_state->topology, session->pending_media_state->topology)) {</span><br><span style="color: hsl(120, 100%, 40%);">+              use_pending = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+              use_active = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+       }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   if (use_pending) {</span><br><span>           pending_media_state = ast_sip_session_media_state_clone(session->pending_media_state);</span><br><span>            if (!pending_media_state) {</span><br><span>                  SCOPE_EXIT_LOG_RTN(LOG_ERROR, "%s: Failed to clone pending media state\n", session_name);</span><br><span>          }</span><br><span style="color: hsl(120, 100%, 40%);">+     }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+ if (use_active) {</span><br><span>            active_media_state = ast_sip_session_media_state_clone(session->active_media_state);</span><br><span>              if (!active_media_state) {</span><br><span>                   ast_sip_session_media_state_free(pending_media_state);</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/15655">change 15655</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/+/15655"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: I61313cca7fc571144338aac826091791b87b6e17 </div>
<div style="display:none"> Gerrit-Change-Number: 15655 </div>
<div style="display:none"> Gerrit-PatchSet: 3 </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: George Joseph <gjoseph@digium.com> </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>