You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
lua/SOURCES/lua-5.4.1-bug11.patch

31 lines
1.1 KiB

From a585eae6e7ada1ca9271607a4f48dfb17868ab7b Mon Sep 17 00:00:00 2001
From: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date: Mon, 27 Jul 2020 12:01:38 -0300
Subject: [PATCH] Fixed bug: Negation overflow in getlocal/setlocal
Adjusted for 5.3
---
diff --git a/src/ldebug.c b/src/ldebug.c
index f1835890..a44e5439 100644
--- a/src/ldebug.c
+++ b/src/ldebug.c
@@ -133,7 +133,7 @@ static const char *upvalname (Proto *p, int uv) {
static const char *findvararg (CallInfo *ci, int n, StkId *pos) {
int nparams = clLvalue(ci->func)->p->numparams;
- if (n >= cast_int(ci->u.l.base - ci->func) - nparams)
+ if (n < cast_int(ci->u.l.base - ci->func) - nparams) /* 'n' is negative */
return NULL; /* no such vararg */
else {
*pos = ci->func + nparams + n;
@@ -148,7 +148,7 @@ static const char *findlocal (lua_State *L, CallInfo *ci, int n,
StkId base;
if (isLua(ci)) {
if (n < 0) /* access to vararg values? */
- return findvararg(ci, -n, pos);
+ return findvararg(ci, n, pos);
else {
base = ci->u.l.base;
name = luaF_getlocalname(ci_func(ci)->p, n, currentpc(ci));