Avoid underflows in 'luaF_getlocalname'

A call like 'debug.getlocal(test, -2147483648)' could decrement
-2147483648, causing an underflow. (As this happens in a debug function,
the fix was not strictly necessary, but it has no cost in the generated
code.)
This commit is contained in:
Roberto I
2026-10-12 16:12:40 -03:00
parent 745b96db54
commit 80f3ecc44f
5 changed files with 8 additions and 7 deletions
+1 -1
View File
@@ -853,7 +853,7 @@ static int listlocals (lua_State *L) {
luaL_argcheck(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1),
1, "Lua function expected");
p = getproto(obj_at(L, 1));
while ((name = luaF_getlocalname(p, ++i, pc)) != NULL)
while ((name = luaF_getlocalname(p, cast_uint(++i), pc)) != NULL)
lua_pushstring(L, name);
return i-1;
}