diff --git a/libfaad/sbr_hfadj.c b/libfaad/sbr_hfadj.c index 3f310b81..dda1ce8e 100644 --- a/libfaad/sbr_hfadj.c +++ b/libfaad/sbr_hfadj.c @@ -485,6 +485,12 @@ static void calculate_gain(sbr_info *sbr, sbr_hfadj_info *adj, uint8_t ch) ml1 = sbr->f_table_lim[sbr->bs_limiter_bands][k]; ml2 = sbr->f_table_lim[sbr->bs_limiter_bands][k+1]; + if (ml1 > MAX_M) + ml1 = MAX_M; + + if (ml2 > MAX_M) + ml2 = MAX_M; + /* calculate the accumulated E_orig and E_curr over the limiter band */ for (m = ml1; m < ml2; m++) @@ -949,6 +955,12 @@ static void calculate_gain(sbr_info *sbr, sbr_hfadj_info *adj, uint8_t ch) ml1 = sbr->f_table_lim[sbr->bs_limiter_bands][k]; ml2 = sbr->f_table_lim[sbr->bs_limiter_bands][k+1]; + if (ml1 > MAX_M) + ml1 = MAX_M; + + if (ml2 > MAX_M) + ml2 = MAX_M; + /* calculate the accumulated E_orig and E_curr over the limiter band */ for (m = ml1; m < ml2; m++) @@ -1193,6 +1205,12 @@ static void calculate_gain(sbr_info *sbr, sbr_hfadj_info *adj, uint8_t ch) ml1 = sbr->f_table_lim[sbr->bs_limiter_bands][k]; ml2 = sbr->f_table_lim[sbr->bs_limiter_bands][k+1]; + if (ml1 > MAX_M) + ml1 = MAX_M; + + if (ml2 > MAX_M) + ml2 = MAX_M; + /* calculate the accumulated E_orig and E_curr over the limiter band */ for (m = ml1; m < ml2; m++) diff --git a/libfaad/syntax.c b/libfaad/syntax.c index f8e808c2..e7fb1138 100644 --- a/libfaad/syntax.c +++ b/libfaad/syntax.c @@ -344,6 +344,12 @@ static void decode_sce_lfe(NeAACDecStruct *hDecoder, can become 2 when some form of Parametric Stereo coding is used */ + if (hDecoder->frame && hDecoder->element_id[hDecoder->fr_ch_ele] != id_syn_ele) { + /* element inconsistency */ + hInfo->error = 21; + return; + } + /* save the syntax element id */ hDecoder->element_id[hDecoder->fr_ch_ele] = id_syn_ele; @@ -395,6 +401,12 @@ static void decode_cpe(NeAACDecStruct *hDecoder, NeAACDecFrameInfo *hInfo, bitfi return; } + if (hDecoder->frame && hDecoder->element_id[hDecoder->fr_ch_ele] != id_syn_ele) { + /* element inconsistency */ + hInfo->error = 21; + return; + } + /* save the syntax element id */ hDecoder->element_id[hDecoder->fr_ch_ele] = id_syn_ele;