<p>Sean Bright has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/15596">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">res_musiconhold.c: Plug ref leak caused by ao2_replace() misuse.<br><br>ao2_replace() bumps the reference count of the object that is doing the<br>replacing, which is not what we want. We just want to drop the old ref<br>on the old object and update the pointer to point to the new object.<br><br>Pointed out by George Joseph in #asterisk-dev<br><br>Change-Id: Ie8167ed3d4b52b9d1ea2d785f885e8c27206743d<br>---<br>M res/res_musiconhold.c<br>1 file changed, 4 insertions(+), 2 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/96/15596/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/res/res_musiconhold.c b/res/res_musiconhold.c</span><br><span>index 736ddc6..9811ea7 100644</span><br><span>--- a/res/res_musiconhold.c</span><br><span>+++ b/res/res_musiconhold.c</span><br><span>@@ -1209,7 +1209,8 @@</span><br><span> </span><br><span>              /* We don't need to lock here because we are the thread that</span><br><span>              * created this mohclass and we haven't published it yet */</span><br><span style="color: hsl(0, 100%, 40%);">-         ao2_replace(mohclass->files, playlist_entries);</span><br><span style="color: hsl(120, 100%, 40%);">+            ao2_ref(mohclass->files, -1);</span><br><span style="color: hsl(120, 100%, 40%);">+              mohclass->files = playlist_entries;</span><br><span>       }</span><br><span> }</span><br><span> </span><br><span>@@ -1306,7 +1307,8 @@</span><br><span>   AST_VECTOR_COMPACT(files);</span><br><span> </span><br><span>       ao2_lock(class);</span><br><span style="color: hsl(0, 100%, 40%);">-        ao2_replace(class->files, files);</span><br><span style="color: hsl(120, 100%, 40%);">+  ao2_ref(class->files, -1);</span><br><span style="color: hsl(120, 100%, 40%);">+ class->files = files;</span><br><span>     ao2_unlock(class);</span><br><span> </span><br><span>       return AST_VECTOR_SIZE(files);</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/15596">change 15596</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/+/15596"/><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: Ie8167ed3d4b52b9d1ea2d785f885e8c27206743d </div>
<div style="display:none"> Gerrit-Change-Number: 15596 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Sean Bright <sean.bright@gmail.com> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>