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
@@ -300,7 +300,7 @@ void luaF_freeproto (lua_State *L, Proto *f) {
** Look for n-th local variable at line 'line' in function 'func'.
** Returns NULL if not found.
*/
const char *luaF_getlocalname (const Proto *f, int local_number, int pc) {
const char *luaF_getlocalname (const Proto *f, unsigned local_number, int pc) {
int i;
for (i = 0; i<f->sizelocvars && f->locvars[i].startpc <= pc; i++) {
if (pc < f->locvars[i].endpc) { /* is variable active? */