From c3b379bf50c8819c61daa3afd9f21d9ec5708bd5 Mon Sep 17 00:00:00 2001 From: Mike Pall Date: Mon, 25 May 2026 01:26:26 +0200 Subject: FFI: Prevent sanitizer warning in carith_ptr(). Reported by Sergey Bronnikov. #1459 --- src/lj_carith.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lj_carith.c b/src/lj_carith.c index e3287de9d..b1da0e2c3 100644 --- a/src/lj_carith.c +++ b/src/lj_carith.c @@ -133,7 +133,7 @@ static int carith_ptr(lua_State *L, CTState *cts, CDArith *ca, MMS mm) return 0; lj_cconv_ct_ct(cts, ctype_get(cts, CTID_INT_PSZ), ca->ct[1], (uint8_t *)&idx, ca->p[1], 0); - if (mm == MM_sub) idx = -idx; + if (mm == MM_sub) idx = (ptrdiff_t)(~(uintptr_t)idx+1u); } else if (mm == MM_add && ctype_isnum(ctp->info) && (ctype_isptr(ca->ct[1]->info) || ctype_isrefarray(ca->ct[1]->info))) { /* Swap pointer and index. */ -- cgit v1.2.3-55-g6feb