<p>Joshua Colp has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/14450">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">res_rtp_asterisk: Re-order RTP destruction.<br><br>The destructor for RTP deallocated transport resources<br>before terminating the ICE support. This could result<br>in a crash as the thread handling ICE would access already<br>freed parts of the RTP data.<br><br>This change re-orders the destruction so that ICE is<br>stopped before destroying things.<br><br>ASTERISK-28885<br><br>Change-Id: Ie71add549f12b6cdea7e9dbf976d1bd1d2fc0bdc<br>---<br>M res/res_rtp_asterisk.c<br>1 file changed, 33 insertions(+), 33 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/50/14450/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/res/res_rtp_asterisk.c b/res/res_rtp_asterisk.c</span><br><span>index 8e1fb37..167a766 100644</span><br><span>--- a/res/res_rtp_asterisk.c</span><br><span>+++ b/res/res_rtp_asterisk.c</span><br><span>@@ -3429,39 +3429,6 @@</span><br><span>         ast_rtp_dtls_stop(instance);</span><br><span> #endif</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-      /* Destroy the smoother that was smoothing out audio if present */</span><br><span style="color: hsl(0, 100%, 40%);">-      if (rtp->smoother) {</span><br><span style="color: hsl(0, 100%, 40%);">-         ast_smoother_free(rtp->smoother);</span><br><span style="color: hsl(0, 100%, 40%);">-    }</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-       /* Close our own socket so we no longer get packets */</span><br><span style="color: hsl(0, 100%, 40%);">-  if (rtp->s > -1) {</span><br><span style="color: hsl(0, 100%, 40%);">-                close(rtp->s);</span><br><span style="color: hsl(0, 100%, 40%);">-       }</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-       /* Destroy RTCP if it was being used */</span><br><span style="color: hsl(0, 100%, 40%);">- if (rtp->rtcp) {</span><br><span style="color: hsl(0, 100%, 40%);">-             /*</span><br><span style="color: hsl(0, 100%, 40%);">-               * It is not possible for there to be an active RTCP scheduler</span><br><span style="color: hsl(0, 100%, 40%);">-           * entry at this point since it holds a reference to the</span><br><span style="color: hsl(0, 100%, 40%);">-                 * RTP instance while it's active.</span><br><span style="color: hsl(0, 100%, 40%);">-           */</span><br><span style="color: hsl(0, 100%, 40%);">-             if (rtp->rtcp->s > -1 && rtp->s != rtp->rtcp->s) {</span><br><span style="color: hsl(0, 100%, 40%);">-                    close(rtp->rtcp->s);</span><br><span style="color: hsl(0, 100%, 40%);">-              }</span><br><span style="color: hsl(0, 100%, 40%);">-               ast_free(rtp->rtcp->local_addr_str);</span><br><span style="color: hsl(0, 100%, 40%);">-              ast_free(rtp->rtcp);</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-       /* Destroy RED if it was being used */</span><br><span style="color: hsl(0, 100%, 40%);">-  if (rtp->red) {</span><br><span style="color: hsl(0, 100%, 40%);">-              ao2_unlock(instance);</span><br><span style="color: hsl(0, 100%, 40%);">-           AST_SCHED_DEL(rtp->sched, rtp->red->schedid);</span><br><span style="color: hsl(0, 100%, 40%);">-          ao2_lock(instance);</span><br><span style="color: hsl(0, 100%, 40%);">-             ast_free(rtp->red);</span><br><span style="color: hsl(0, 100%, 40%);">-          rtp->red = NULL;</span><br><span style="color: hsl(0, 100%, 40%);">-     }</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span> #ifdef HAVE_PJPROJECT</span><br><span>   pj_thread_register_check();</span><br><span> </span><br><span>@@ -3519,6 +3486,39 @@</span><br><span>     }</span><br><span> #endif</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+       /* Destroy the smoother that was smoothing out audio if present */</span><br><span style="color: hsl(120, 100%, 40%);">+    if (rtp->smoother) {</span><br><span style="color: hsl(120, 100%, 40%);">+               ast_smoother_free(rtp->smoother);</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%);">+   /* Close our own socket so we no longer get packets */</span><br><span style="color: hsl(120, 100%, 40%);">+        if (rtp->s > -1) {</span><br><span style="color: hsl(120, 100%, 40%);">+              close(rtp->s);</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%);">+   /* Destroy RTCP if it was being used */</span><br><span style="color: hsl(120, 100%, 40%);">+       if (rtp->rtcp) {</span><br><span style="color: hsl(120, 100%, 40%);">+           /*</span><br><span style="color: hsl(120, 100%, 40%);">+             * It is not possible for there to be an active RTCP scheduler</span><br><span style="color: hsl(120, 100%, 40%);">+                 * entry at this point since it holds a reference to the</span><br><span style="color: hsl(120, 100%, 40%);">+               * RTP instance while it's active.</span><br><span style="color: hsl(120, 100%, 40%);">+                 */</span><br><span style="color: hsl(120, 100%, 40%);">+           if (rtp->rtcp->s > -1 && rtp->s != rtp->rtcp->s) {</span><br><span style="color: hsl(120, 100%, 40%);">+                  close(rtp->rtcp->s);</span><br><span style="color: hsl(120, 100%, 40%);">+            }</span><br><span style="color: hsl(120, 100%, 40%);">+             ast_free(rtp->rtcp->local_addr_str);</span><br><span style="color: hsl(120, 100%, 40%);">+            ast_free(rtp->rtcp);</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%);">+   /* Destroy RED if it was being used */</span><br><span style="color: hsl(120, 100%, 40%);">+        if (rtp->red) {</span><br><span style="color: hsl(120, 100%, 40%);">+            ao2_unlock(instance);</span><br><span style="color: hsl(120, 100%, 40%);">+         AST_SCHED_DEL(rtp->sched, rtp->red->schedid);</span><br><span style="color: hsl(120, 100%, 40%);">+                ao2_lock(instance);</span><br><span style="color: hsl(120, 100%, 40%);">+           ast_free(rtp->red);</span><br><span style="color: hsl(120, 100%, 40%);">+                rtp->red = NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+   }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>  ao2_cleanup(rtp->lasttxformat);</span><br><span>   ao2_cleanup(rtp->lastrxformat);</span><br><span>   ao2_cleanup(rtp->f.subclass.format);</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/14450">change 14450</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/+/14450"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 13 </div>
<div style="display:none"> Gerrit-Change-Id: Ie71add549f12b6cdea7e9dbf976d1bd1d2fc0bdc </div>
<div style="display:none"> Gerrit-Change-Number: 14450 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Joshua Colp <jcolp@sangoma.com> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>