From 8f421c81ec6aaae0bcd80e01f4353de200afbbc5 Mon Sep 17 00:00:00 2001 From: Mike Pall Date: Mon, 25 May 2026 01:28:32 +0200 Subject: Prevent sanitizer warnings for lj_tab_new*() and table.new(). Reported by Sergey Bronnikov. #1458 --- src/lj_api.c | 2 +- src/lj_tab.c | 4 ++-- src/lj_tab.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/lj_api.c b/src/lj_api.c index 6369c17db..f972a760b 100644 --- a/src/lj_api.c +++ b/src/lj_api.c @@ -708,7 +708,7 @@ LUA_API void lua_pushlightuserdata(lua_State *L, void *p) LUA_API void lua_createtable(lua_State *L, int narray, int nrec) { lj_gc_check(L); - settabV(L, L->top, lj_tab_new_ah(L, narray, nrec)); + settabV(L, L->top, lj_tab_new_ah(L, (uint32_t)narray, (uint32_t)nrec)); incr_top(L); } diff --git a/src/lj_tab.c b/src/lj_tab.c index c63117fa4..f9dd541be 100644 --- a/src/lj_tab.c +++ b/src/lj_tab.c @@ -145,9 +145,9 @@ GCtab *lj_tab_new(lua_State *L, uint32_t asize, uint32_t hbits) } /* The API of this function conforms to lua_createtable(). */ -GCtab *lj_tab_new_ah(lua_State *L, int32_t a, int32_t h) +GCtab *lj_tab_new_ah(lua_State *L, uint32_t a, uint32_t h) { - return lj_tab_new(L, (uint32_t)(a > 0 ? a+1 : 0), hsize2hbits(h)); + return lj_tab_new(L, a ? a+1 : 0, hsize2hbits(h)); } #if LJ_HASJIT diff --git a/src/lj_tab.h b/src/lj_tab.h index f1712e45f..9822c3266 100644 --- a/src/lj_tab.h +++ b/src/lj_tab.h @@ -53,7 +53,7 @@ static LJ_AINLINE Node *hashmask(const GCtab *t, uint32_t hash) #define hsize2hbits(s) ((s) ? ((s)==1 ? 1 : 1+lj_fls((uint32_t)((s)-1))) : 0) LJ_FUNCA GCtab *lj_tab_new(lua_State *L, uint32_t asize, uint32_t hbits); -LJ_FUNC GCtab *lj_tab_new_ah(lua_State *L, int32_t a, int32_t h); +LJ_FUNC GCtab *lj_tab_new_ah(lua_State *L, uint32_t a, uint32_t h); #if LJ_HASJIT LJ_FUNC GCtab * LJ_FASTCALL lj_tab_new1(lua_State *L, uint32_t ahsize); #endif -- cgit v1.2.3-55-g6feb