Added boundary check for array access as a short-term way of fixing the bug of out-of-bounds reads into the array

BUG=chromium:529527, chromium:529552

Review URL: https://codereview.webrtc.org/1338993003

Cr-Commit-Position: refs/heads/master@{#9930}
This commit is contained in:
peah
2015-09-14 06:54:00 -07:00
committed by Commit bot
parent 5e023eb337
commit fc9dd1710d

View File

@ -820,8 +820,11 @@ static void UpdateDelayMetrics(AecCore* self) {
// negative (anti-causal system) or larger than the AEC filter length.
{
int num_delays_out_of_bounds = self->num_delay_values;
const int histogram_length = sizeof(self->delay_histogram) /
sizeof(self->delay_histogram[0]);
for (i = lookahead; i < lookahead + self->num_partitions; ++i) {
num_delays_out_of_bounds -= self->delay_histogram[i];
if (i < histogram_length)
num_delays_out_of_bounds -= self->delay_histogram[i];
}
self->fraction_poor_delays = (float)num_delays_out_of_bounds /
self->num_delay_values;