From f874b377fb9be35147ceda399fb2653038557d1f Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Thu, 5 Jun 2025 09:31:10 +0200 Subject: [PATCH] Add FIX_USAN_BASOP_UTIL_DIVIDE3232 to address USAN in BASOP_Util_Divide3232_Scale_newton --- lib_com/basop_util.c | 4 ++++ lib_com/options.h | 1 + 2 files changed, 5 insertions(+) diff --git a/lib_com/basop_util.c b/lib_com/basop_util.c index e52f404f6..3d6324783 100644 --- a/lib_com/basop_util.c +++ b/lib_com/basop_util.c @@ -1409,7 +1409,11 @@ Word32 BASOP_Util_Divide3232_Scale_newton( Word32 x, Word32 y, Word16 *s ) *s = 0; return ( (Word32) 0 ); } +#ifdef FIX_USAN_BASOP_UTIL_DIVIDE3232 + IF( EQ_32( y, (Word32) 0x80000000 ) ) +#else IF( EQ_32( y, 0x80000000 ) ) +#endif { /* Division by -1.0: same as negation of numerator */ /* Return normalized negated numerator */ diff --git a/lib_com/options.h b/lib_com/options.h index a5d5a4846..fe44eae00 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -105,5 +105,6 @@ #define REMOVE_EVS_DUPLICATES /* remove core-coder duplicated functions, ACELP low-band decoder */ #define FIX_1713_EXP /* VA: proposed correction to exp in ic-BWE*/ +#define FIX_USAN_BASOP_UTIL_DIVIDE3232 /* Eri: Fix USAN error in BASOP_Util_Divide3232_Scale_newton by adding explicit type cast for -1 in hex */ #endif -- GitLab