Skip to content

Commit

Permalink
Fix for divide-by-zero in ixheaacd_pre_processing
Browse files Browse the repository at this point in the history
These changes handle the divide-by-zero runtime error reported
while calculating the energy because the start sample and end sample
were coming same.

Bug: ossFuzz:62766
Test: poc in bug
  • Loading branch information
ShashankPathmudi authored and sandeshvenkatesh committed Sep 29, 2023
1 parent 3c83299 commit f48c9be
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions decoder/ixheaacd_sbrdec_lpfuncs.c
Original file line number Diff line number Diff line change
Expand Up @@ -933,23 +933,25 @@ VOID ixheaacd_pre_processing(FLOAT32 ptr_src_buf_real[][64],
FLOAT32 poly_coeff[4];
FLOAT32 mean_enrg = 0;
FLOAT32 low_env_slope[64];
FLOAT32 low_env[64];
FLOAT32 low_env[64] = {0};
FLOAT32 a0;
FLOAT32 a1;
FLOAT32 a2;
FLOAT32 a3;

for (k = 0; k < num_bands; k++) {
FLOAT32 temp = 0;
for (i = start_sample; i < end_sample; i++) {
temp += ptr_src_buf_real[i][k] * ptr_src_buf_real[i][k] +
ptr_src_buf_imag[i][k] * ptr_src_buf_imag[i][k];
if (num_bands != 0 && end_sample != start_sample) {
for (k = 0; k < num_bands; k++) {
FLOAT32 temp = 0;
for (i = start_sample; i < end_sample; i++) {
temp += ptr_src_buf_real[i][k] * ptr_src_buf_real[i][k] +
ptr_src_buf_imag[i][k] * ptr_src_buf_imag[i][k];
}
temp /= (end_sample - start_sample);
low_env[k] = (FLOAT32)(10 * log10(temp + 1));
mean_enrg = mean_enrg + low_env[k];
}
temp /= (end_sample - start_sample);
low_env[k] = (FLOAT32)(10 * log10(temp + 1));
mean_enrg = mean_enrg + low_env[k];
mean_enrg /= num_bands;
}
mean_enrg /= num_bands;

ixheaacd_polyfit(num_bands, low_env, poly_coeff);

Expand Down

0 comments on commit f48c9be

Please sign in to comment.