diff options
author | Shashank Pathmudi <shashank.pathmudi@ittiam.com> | 2023-09-29 17:44:14 +0530 |
---|---|---|
committer | sandeshvenkatesh <89826624+sandeshvenkatesh@users.noreply.github.com> | 2023-09-29 18:08:43 +0530 |
commit | f48c9bea6406028f4599306e609f60bb8a022374 (patch) | |
tree | a848aaff4c97feb8179af1cea2cebfc564b0654e | |
parent | 3c8329953cd596b4f5b2163910be223fb6a52e3c (diff) | |
download | libxaac-f48c9bea6406028f4599306e609f60bb8a022374.tar.gz |
Fix for divide-by-zero in ixheaacd_pre_processing
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
-rw-r--r-- | decoder/ixheaacd_sbrdec_lpfuncs.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/decoder/ixheaacd_sbrdec_lpfuncs.c b/decoder/ixheaacd_sbrdec_lpfuncs.c index d828d2f..a14a869 100644 --- a/decoder/ixheaacd_sbrdec_lpfuncs.c +++ b/decoder/ixheaacd_sbrdec_lpfuncs.c @@ -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); |