From 25a2dac2bcab84d1f1ce8c49b673b4a032a29a4a Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Thu, 24 Oct 2024 15:33:25 -0300 Subject: Always use unsigned int for indexing table-arrays --- ltable.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'ltable.c') diff --git a/ltable.c b/ltable.c index bf44e82e..a36a993f 100644 --- a/ltable.c +++ b/ltable.c @@ -951,7 +951,7 @@ lu_byte luaH_getint (Table *t, lua_Integer key, TValue *res) { if (keyinarray(t, key)) { lu_byte tag = *getArrTag(t, key - 1); if (!tagisempty(tag)) - farr2val(t, key - 1, tag, res); + farr2val(t, cast_uint(key) - 1, tag, res); return tag; } else @@ -1062,7 +1062,7 @@ int luaH_psetint (Table *t, lua_Integer key, TValue *val) { if (keyinarray(t, key)) { lu_byte *tag = getArrTag(t, key - 1); if (!tagisempty(*tag) || checknoTM(t->metatable, TM_NEWINDEX)) { - fval2arr(t, key - 1, tag, val); + fval2arr(t, cast_uint(key) - 1, tag, val); return HOK; /* success */ } else @@ -1118,7 +1118,7 @@ void luaH_finishset (lua_State *L, Table *t, const TValue *key, } else { /* array entry */ hres = ~hres; /* real index */ - obj2arr(t, hres, value); + obj2arr(t, cast_uint(hres), value); } } @@ -1140,7 +1140,7 @@ void luaH_set (lua_State *L, Table *t, const TValue *key, TValue *value) { */ void luaH_setint (lua_State *L, Table *t, lua_Integer key, TValue *value) { if (keyinarray(t, key)) - obj2arr(t, key - 1, value); + obj2arr(t, cast_uint(key) - 1, value); else { int ok = rawfinishnodeset(getintfromhash(t, key), value); if (!ok) { -- cgit v1.2.3-55-g6feb