FFI: Prevent sanitizer warning in carith_ptr().

Reported by Sergey Bronnikov. #1459
This commit is contained in:
Mike Pall 2026-05-25 01:26:26 +02:00
parent 86d414f5ca
commit c3b379bf50

View File

@ -133,7 +133,7 @@ static int carith_ptr(lua_State *L, CTState *cts, CDArith *ca, MMS mm)
return 0; return 0;
lj_cconv_ct_ct(cts, ctype_get(cts, CTID_INT_PSZ), ca->ct[1], lj_cconv_ct_ct(cts, ctype_get(cts, CTID_INT_PSZ), ca->ct[1],
(uint8_t *)&idx, ca->p[1], 0); (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) && } else if (mm == MM_add && ctype_isnum(ctp->info) &&
(ctype_isptr(ca->ct[1]->info) || ctype_isrefarray(ca->ct[1]->info))) { (ctype_isptr(ca->ct[1]->info) || ctype_isrefarray(ca->ct[1]->info))) {
/* Swap pointer and index. */ /* Swap pointer and index. */