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

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">res_speech: Bump reference on format object<br><br>Properly bump reference on format object to avoid memory corruption on double free<br><br>ASTERISK-29040 #close<br><br>Change-Id: Ic5a7faabfe2ef965ddb024186e1de7ca4542e2a3<br>---<br>M res/res_speech.c<br>1 file changed, 4 insertions(+), 3 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/res/res_speech.c b/res/res_speech.c</span><br><span>index 31ad61a..57f6fa6 100644</span><br><span>--- a/res/res_speech.c</span><br><span>+++ b/res/res_speech.c</span><br><span>@@ -220,16 +220,17 @@</span><br><span>   new_speech->engine = engine;</span><br><span> </span><br><span>  /* Can't forget the format audio is going to be in */</span><br><span style="color: hsl(0, 100%, 40%);">-       new_speech->format = best;</span><br><span style="color: hsl(120, 100%, 40%);">+ new_speech->format = ao2_bump(best);</span><br><span> </span><br><span>  /* We are not ready to accept audio yet */</span><br><span>   ast_speech_change_state(new_speech, AST_SPEECH_STATE_NOT_READY);</span><br><span> </span><br><span>         /* Pass ourselves to the engine so they can set us up some more and if they error out then do not create a structure */</span><br><span style="color: hsl(0, 100%, 40%);">- if (engine->create(new_speech, best)) {</span><br><span style="color: hsl(120, 100%, 40%);">+    if (engine->create(new_speech, new_speech->format)) {</span><br><span>          ast_mutex_destroy(&new_speech->lock);</span><br><span style="color: hsl(120, 100%, 40%);">+          ao2_ref(new_speech->format, -1);</span><br><span>          ast_free(new_speech);</span><br><span style="color: hsl(0, 100%, 40%);">-           new_speech = NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+            return NULL;</span><br><span>         }</span><br><span> </span><br><span>        return new_speech;</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/14800">change 14800</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/+/14800"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 18 </div>
<div style="display:none"> Gerrit-Change-Id: Ic5a7faabfe2ef965ddb024186e1de7ca4542e2a3 </div>
<div style="display:none"> Gerrit-Change-Number: 14800 </div>
<div style="display:none"> Gerrit-PatchSet: 2 </div>
<div style="display:none"> Gerrit-Owner: Nickolay V. Shmyrev <nshmyrev@alphacephei.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: Kevin Harwell <kharwell@digium.com> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>