From c06ef5727b49bc4c5dc8ae062758146b323b9274 Mon Sep 17 00:00:00 2001 From: Fyodor Kyslov Date: Fri, 25 Sep 2026 22:27:02 +0000 Subject: [PATCH] Clamp left_shift in oapv_dquant() to prevent shift UB Clamp left_shift = oapv_clip3(0, 30, -shift) in oapv_dquant() as defense-in-depth against out-of-range shift exponents. Signed-off-by: Fyodor Kyslov --- src/oapv_tq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/oapv_tq.c b/src/oapv_tq.c index b2a85393..f52f8dfb 100644 --- a/src/oapv_tq.c +++ b/src/oapv_tq.c @@ -407,7 +407,7 @@ static void oapv_dquant(s16 *coef, s16 q_matrix[OAPV_BLK_D], int log2_w, int log } } else { - int left_shift = -shift; + int left_shift = oapv_clip3(0, 30, -shift); for(i = 0; i < pixels; i++) { lev = (coef[i] * q_matrix[i]) << left_shift; coef[i] = (s16)oapv_clip3(-32768, 32767, lev);