Commit f3edea3a authored by vaclav's avatar vaclav
Browse files

fix issue 618 - UBSAN: division-by-zero in stereo bitrate switching; under...

fix issue 618 - UBSAN: division-by-zero in stereo bitrate switching; under FIX_618_STEREO_SW_DIV_BY_ZERO
parent 481a7b16
Loading
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -209,6 +209,8 @@
#define FIX_615_UBSAN_SPAR_TO_DIRAC                     /*Dlb : Fix for UBSAN issue 615*/
#define FIX_626_VARIABLE_TYPE_MDCT_CONC                 /* FhG: trivial fix to fix USAN error */
#define FIX_616_DIV_ZERO_MCT                            /*FhG : Fix UBSAN division by zero error of issue 616*/
#define FIX_618_STEREO_SW_DIV_BY_ZERO                   /* VA: fix issue 618 - UBSAN: division-by-zero in stereo bitrate switching */


/* ################## End BE DEVELOPMENT switches ######################### */

+4 −0
Original line number Diff line number Diff line
@@ -1259,7 +1259,11 @@ void swb_tbe_enc(
        GainFrame *= temp;
    }

#ifdef FIX_618_STEREO_SW_DIV_BY_ZERO
    if ( st->element_mode > EVS_MONO && st->L_frame != st->last_L_frame && ( st->last_extl == SWB_TBE || st->last_extl == FB_TBE ) && st->coder_type == TRANSITION && st->coder_type_raw != VOICED && st->clas == VOICED_CLAS && st->last_clas == VOICED_CLAS && ( 3.0f * voice_factors[0] < voice_factors[( st->L_frame >> 6 ) - 1] ) )
#else
    if ( st->element_mode > EVS_MONO && st->L_frame != st->last_L_frame && st->coder_type == TRANSITION && st->coder_type_raw != VOICED && st->clas == VOICED_CLAS && st->last_clas == VOICED_CLAS && ( 3.0f * voice_factors[0] < voice_factors[( st->L_frame >> 6 ) - 1] ) )
#endif
    {
        float fac = GainFrame / hBWE_TD->prev_gainFr_SHB;