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