Skip to content

Commit

Permalink
Fixed bug: Negation overflow in getlocal/setlocal
Browse files Browse the repository at this point in the history
  • Loading branch information
roberto-ieru committed Jul 27, 2020
1 parent d2c2e32 commit a585eae
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions ldebug.c
Expand Up @@ -188,8 +188,8 @@ static const char *upvalname (const Proto *p, int uv) {
static const char *findvararg (CallInfo *ci, int n, StkId *pos) {
if (clLvalue(s2v(ci->func))->p->is_vararg) {
int nextra = ci->u.l.nextraargs;
if (n <= nextra) {
*pos = ci->func - nextra + (n - 1);
if (n >= -nextra) { /* 'n' is negative */
*pos = ci->func - nextra - (n + 1);
return "(vararg)"; /* generic name for any vararg */
}
}
Expand All @@ -202,7 +202,7 @@ const char *luaG_findlocal (lua_State *L, CallInfo *ci, int n, StkId *pos) {
const char *name = NULL;
if (isLua(ci)) {
if (n < 0) /* access to vararg values? */
return findvararg(ci, -n, pos);
return findvararg(ci, n, pos);
else
name = luaF_getlocalname(ci_func(ci)->p, n, currentpc(ci));
}
Expand Down

0 comments on commit a585eae

Please sign in to comment.