Skip to content

Commit

Permalink
Fix for divide-by-zero in ixheaacd_sbr_env_calc
Browse files Browse the repository at this point in the history
These changes handle the divide-by-zero runtime error
reported while calculating energy tone.

Bug: ossFuzz:63248
Test: poc in bug
  • Loading branch information
ShashankPathmudi authored and divya-bm committed Oct 20, 2023
1 parent 2fb847d commit b1a2002
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions decoder/ixheaacd_esbr_envcal.c
Original file line number Diff line number Diff line change
Expand Up @@ -365,12 +365,13 @@ WORD32 ixheaacd_sbr_env_calc(ia_sbr_frame_info_data_struct *frame_data, FLOAT32
(frame_data->qmapped_pvc[c][t] + guard))
: nrg_tone_pvc[c][t]);

nrg_tone_pvc[c][t] = (FLOAT32)(
((*harm_flag_varlen)[c] &&
(t >= frame_data->sin_start_for_cur_top ||
(*harm_flag_varlen_prev)[c + sub_band_start]))
? sqrt(nrg_ref_pvc[c][t] * tmp / prev_env_noise_level[o])
: nrg_tone_pvc[c][t]);
nrg_tone_pvc[c][t] =
(FLOAT32)(((*harm_flag_varlen)[c] &&
(t >= frame_data->sin_start_for_cur_top ||
(*harm_flag_varlen_prev)[c + sub_band_start]))
? sqrt(nrg_ref_pvc[c][t] * tmp /
(prev_env_noise_level[o] + guard))
: nrg_tone_pvc[c][t]);

} else {
if (noise_absc_flag) {
Expand Down Expand Up @@ -522,7 +523,8 @@ WORD32 ixheaacd_sbr_env_calc(ia_sbr_frame_info_data_struct *frame_data, FLOAT32
k < (*lim_table)[limiter_band][c + 1]; k++) {
if (g_max <= nrg_gain_pvc[k][t]) {
noise_level_pvc[k][t] =
noise_level_pvc[k][t] * (g_max / nrg_gain_pvc[k][t]);
(FLOAT32)(noise_level_pvc[k][t] *
(g_max / (nrg_gain_pvc[k][t] + guard)));
nrg_gain_pvc[k][t] = g_max;
}

Expand Down

0 comments on commit b1a2002

Please sign in to comment.