From a3844f1010c5679f5416efd1b3b8bf0a98d61bef Mon Sep 17 00:00:00 2001 From: DeeJayLSP Date: Tue, 29 Jul 2025 21:59:48 -0300 Subject: [PATCH] Fix possible integer overflow in qoa_div --- qoa.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qoa.h b/qoa.h index e11c842..f52b1f1 100644 --- a/qoa.h +++ b/qoa.h @@ -293,7 +293,7 @@ argument, so it can do the division with a cheaper integer multiplication. */ static inline int qoa_div(int v, int scalefactor) { int reciprocal = qoa_reciprocal_tab[scalefactor]; - int n = (v * reciprocal + (1 << 15)) >> 16; + int n = (int)(((long long)v * reciprocal + (1 << 15)) >> 16); n = n + ((v > 0) - (v < 0)) - ((n > 0) - (n < 0)); /* round away from 0 */ return n; }