<p>Jasper van der Neut has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/8220">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">bridges/bridge_simple.c: Protect calls to ast_channel_get_stream_topology<br><br>When calling ast_channel_get_stream_topology the channel must be locked.<br><br>ASTERISK-27259<br><br>Change-Id: I4f8766f0710765e0e88758c2a7aca33fa25ec0f7<br>---<br>M bridges/bridge_simple.c<br>1 file changed, 22 insertions(+), 3 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/20/8220/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/bridges/bridge_simple.c b/bridges/bridge_simple.c<br>index 7ee1966..34a690c 100644<br>--- a/bridges/bridge_simple.c<br>+++ b/bridges/bridge_simple.c<br>@@ -116,11 +116,20 @@<br> static void simple_bridge_request_stream_topology_change(struct ast_channel *chan,<br>     struct ast_stream_topology *requested_topology)<br> {<br>-  struct ast_stream_topology *existing_topology = ast_channel_get_stream_topology(chan);<br>+       struct ast_stream_topology *existing_topology = NULL;<br>         struct ast_stream *stream;<br>    struct ast_format_cap *audio_formats = NULL;<br>  struct ast_stream_topology *new_topology;<br>     int i;<br>+<br>+    ast_channel_lock(chan);<br>+      existing_topology = ast_stream_topology_clone(ast_channel_get_stream_topology(chan));<br>+        ast_channel_unlock(chan);<br>+<br>+ if (!existing_topology) {<br>+            ast_channel_request_stream_topology_change(chan, requested_topology, &simple_bridge);<br>+            return;<br>+      }<br> <br>  /* We find an existing stream with negotiated audio formats that we can place into<br>     * any audio streams in the new topology to ensure that negotiation succeeds. Some<br>@@ -137,6 +146,8 @@<br>               audio_formats = ast_stream_get_formats(stream);<br>               break;<br>        }<br>+<br>+ ast_stream_topology_free(existing_topology);<br> <br>       if (!audio_formats) {<br>                 ast_channel_request_stream_topology_change(chan, requested_topology, &simple_bridge);<br>@@ -170,8 +181,8 @@<br> {<br>    struct ast_channel *c0 = AST_LIST_FIRST(&bridge->channels)->chan;<br>   struct ast_channel *c1 = AST_LIST_LAST(&bridge->channels)->chan;<br>-   struct ast_stream_topology *t0 = ast_channel_get_stream_topology(c0);<br>-        struct ast_stream_topology *t1 = ast_channel_get_stream_topology(c1);<br>+        struct ast_stream_topology *t0 = NULL;<br>+       struct ast_stream_topology *t1 = NULL;<br> <br>     if (bridge_channel) {<br>                 ast_bridge_channel_stream_map(bridge_channel);<br>@@ -185,6 +196,14 @@<br>          return;<br>       }<br> <br>+ ast_channel_lock(c0);<br>+        t0 = ast_channel_get_stream_topology(c0);<br>+    ast_channel_unlock(c0);<br>+<br>+   ast_channel_lock(c1);<br>+        t1 = ast_channel_get_stream_topology(c1);<br>+    ast_channel_unlock(c1);<br>+<br>    /* Align topologies according to size or first channel to join */<br>     if (ast_stream_topology_get_count(t0) < ast_stream_topology_get_count(t1)) {<br>               simple_bridge_request_stream_topology_change(c0, t1);<br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/8220">change 8220</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/8220"/><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-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: I4f8766f0710765e0e88758c2a7aca33fa25ec0f7 </div>
<div style="display:none"> Gerrit-Change-Number: 8220 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Jasper van der Neut <jasper@isotopic.nl> </div>