aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYash Patil <yash.patil@ittiam.com>2023-09-22 17:32:16 +0530
committerDivya B M <89966460+divya-bm@users.noreply.github.com>2023-09-22 19:04:19 +0530
commit29692f1804c2a04ff51a0b2e6c7a909f7a261670 (patch)
tree6073fa0e66460d9cac7187212dfb672db9b4ef44
parentf5edac2d5b53ff34c3019b4705a3165e5ce9230a (diff)
downloadlibxaac-29692f1804c2a04ff51a0b2e6c7a909f7a261670.tar.gz
Fix for Divide-by-zero in ixheaacd_sbr_env_calc
These changes handle the Divide-by-zero runtime error reported while calculating the energy estimation because the consecutive border vectors were coming same. Bug: ossFuzz:62282 Test: poc in bug
-rw-r--r--decoder/ixheaacd_esbr_envcal.c33
1 files changed, 22 insertions, 11 deletions
diff --git a/decoder/ixheaacd_esbr_envcal.c b/decoder/ixheaacd_esbr_envcal.c
index ee9efc6..ebf4ae7 100644
--- a/decoder/ixheaacd_esbr_envcal.c
+++ b/decoder/ixheaacd_esbr_envcal.c
@@ -644,18 +644,29 @@ WORD32 ixheaacd_sbr_env_calc(ia_sbr_frame_info_data_struct *frame_data, FLOAT32
ui = freq_band_table[p_frame_info->freq_res[i]][j + 1];
ui2 = frame_data->pstr_sbr_header->pstr_freq_band_data
->freq_band_tbl_noise[o + 1];
- for (flag = 0, k = li; k < ui; k++) {
- for (nrg = 0, l = rate * p_frame_info->border_vec[i];
- l < rate * p_frame_info->border_vec[i + 1]; l++) {
- nrg += (input_real[l][k] * input_real[l][k]) +
- (input_imag[l][k] * input_imag[l][k]);
+
+ if (p_frame_info->border_vec[i] == p_frame_info->border_vec[i + 1]) {
+ for (flag = 0, k = li; k < ui; k++) {
+ flag = (harmonics[c] &&
+ (i >= trans_env || (*harm_flag_prev)[c + sub_band_start]))
+ ? 1
+ : flag;
+ nrg_est[c++] = 0;
+ }
+ } else {
+ for (flag = 0, k = li; k < ui; k++) {
+ for (nrg = 0, l = rate * p_frame_info->border_vec[i];
+ l < rate * p_frame_info->border_vec[i + 1]; l++) {
+ nrg += (input_real[l][k] * input_real[l][k]) +
+ (input_imag[l][k] * input_imag[l][k]);
+ }
+ flag = (harmonics[c] &&
+ (i >= trans_env || (*harm_flag_prev)[c + sub_band_start]))
+ ? 1
+ : flag;
+ nrg_est[c++] = nrg / (rate * p_frame_info->border_vec[i + 1] -
+ rate * p_frame_info->border_vec[i]);
}
- flag = (harmonics[c] &&
- (i >= trans_env || (*harm_flag_prev)[c + sub_band_start]))
- ? 1
- : flag;
- nrg_est[c++] = nrg / (rate * p_frame_info->border_vec[i + 1] -
- rate * p_frame_info->border_vec[i]);
}
if (!int_mode) {
for (nrg = 0, k = c - (ui - li); k < c; k++) {