<p>Friendly Automation <strong>merged</strong> this change.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/11122">View Change</a></p><div style="white-space:pre-wrap">Approvals:
Joshua C. Colp: Looks good to me, but someone else must approve
mattf: Looks good to me, but someone else must approve
Sean Bright: Looks good to me, approved
Friendly Automation: Approved for Submit
</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">res/res_rtp_asterisk.c: Fixing possible divide by zero<br><br>Currently, when the Asterisk calculates rtp statistics, it uses<br>sample_count as a unsigned integer parameter. This would be fine<br>for most of cases, but in case of large enough number of sample_count,<br>this might be causing the divide by zero error.<br><br>ASTERISK-28321<br><br>Change-Id: If7e0629abaceddd2166eb012456c53033ea26249<br>---<br>M res/res_rtp_asterisk.c<br>1 file changed, 16 insertions(+), 0 deletions(-)<br><br></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 84b2088..6a5fb0a 100644</span><br><span>--- a/res/res_rtp_asterisk.c</span><br><span>+++ b/res/res_rtp_asterisk.c</span><br><span>@@ -3075,6 +3075,14 @@</span><br><span> normdev = normdev * sample_count + sample;</span><br><span> sample_count++;</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+ /*</span><br><span style="color: hsl(120, 100%, 40%);">+ It's possible the sample_count hits the maximum value and back to 0.</span><br><span style="color: hsl(120, 100%, 40%);">+ Set to 1 to prevent the divide by zero crash if the sample_count is 0.</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+ if (sample_count == 0) {</span><br><span style="color: hsl(120, 100%, 40%);">+ sample_count = 1;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> return normdev / sample_count;</span><br><span> }</span><br><span> </span><br><span>@@ -3091,6 +3099,14 @@</span><br><span> stddev = sample_count * stddev;</span><br><span> sample_count++;</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+ /*</span><br><span style="color: hsl(120, 100%, 40%);">+ It's possible the sample_count hits the maximum value and back to 0.</span><br><span style="color: hsl(120, 100%, 40%);">+ Set to 1 to prevent the divide by zero crash if the sample_count is 0.</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+ if (sample_count == 0) {</span><br><span style="color: hsl(120, 100%, 40%);">+ sample_count = 1;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> return stddev +</span><br><span> ( sample_count * SQUARE( (sample - normdev) / sample_count ) ) +</span><br><span> ( SQUARE(sample - normdev_curent) / sample_count );</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/11122">change 11122</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/+/11122"/><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: If7e0629abaceddd2166eb012456c53033ea26249 </div>
<div style="display:none"> Gerrit-Change-Number: 11122 </div>
<div style="display:none"> Gerrit-PatchSet: 2 </div>
<div style="display:none"> Gerrit-Owner: sungtae kim <pchero21@gmail.com> </div>
<div style="display:none"> Gerrit-Reviewer: Friendly Automation </div>
<div style="display:none"> Gerrit-Reviewer: Joshua C. Colp <jcolp@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Sean Bright <sean.bright@gmail.com> </div>
<div style="display:none"> Gerrit-Reviewer: mattf <creslin@digium.com> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>