Commit 4410fe4e authored by sagnowski's avatar sagnowski
Browse files

Fix problems reported by UBSAN in jbm_pcmdsp_apa_fx.c

parent d04a383b
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -95,6 +95,7 @@
#define FIX_2015_PREMPH_SAT_ALT                              /* VA: saturation can happen during preemphasis filtering due to a too aggressive scaling factor, allows preemphis to get 1 more bit headroom */
#define FIX_2178_FL_TO_FX_WITH_OBJ_EDIT_FILE_INTERFACE       /* Nokia: Fixes float  to fx conversion in decoder app with object edit file interface */

#define FIX_2173_UBSAN_IN_JBM_PCMDSP_APA
/* ################### End FIXES switches ########################### */

/* #################### Start BASOP porting switches ############################ */
+8 −0
Original line number Diff line number Diff line
@@ -127,7 +127,11 @@ struct apa_state_t
    UWord16 qualityred;      /* quality reduction threshold */
    UWord16 qualityrise;     /* quality rising for adaptive quality thresholds */

#ifdef FIX_2173_UBSAN_IN_JBM_PCMDSP_APA
    Word16 last_pitch;       /* last pitch/sync position */
#else
    UWord16 last_pitch;       /* last pitch/sync position */
#endif
    UWord16 bad_frame_count;  /* # frames before quality threshold is lowered */
    UWord16 good_frame_count; /* # scaled frames */

@@ -1392,7 +1396,11 @@ static Word8 logarithmic_search_fx( const apa_state_t *ps,

    DO
    {
#ifdef FIX_2173_UBSAN_IN_JBM_PCMDSP_APA
        coeff_max = INT32_MIN; /* will always be overwritten with result of first correlation */
#else
        coeff_max = 0x80000000; /* will always be overwritten with result of first correlation */
#endif
        move32();

        FOR( i = s_start; i < s_start + inlen; i += css * ps->num_channels )