aboutsummaryrefslogtreecommitdiff
path: root/lparser.c
diff options
context:
space:
mode:
authorRoberto I <roberto@inf.puc-rio.br>2025-10-10 13:22:19 -0300
committerRoberto I <roberto@inf.puc-rio.br>2025-10-10 13:22:19 -0300
commit3347c9d32d4d91b6139bff475c78cf0c4796e2a7 (patch)
tree008f1f82a5481149ce07328a188b72b535409f84 /lparser.c
parent25c54fe60e22d05cdfaa48c64372d354efa59547 (diff)
downloadlua-3347c9d32d4d91b6139bff475c78cf0c4796e2a7.tar.gz
lua-3347c9d32d4d91b6139bff475c78cf0c4796e2a7.tar.bz2
lua-3347c9d32d4d91b6139bff475c78cf0c4796e2a7.zip
Initialization of too many locals break assertion
The check for limit of local variables is made after generating code to initialize them. If there are too many local variables not initialized, the coding of instruction OP_LOADNIL could overflow an argument.
Diffstat (limited to '')
-rw-r--r--lparser.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/lparser.c b/lparser.c
index 408b8e21..dc646fea 100644
--- a/lparser.c
+++ b/lparser.c
@@ -547,6 +547,7 @@ static void singlevar (LexState *ls, expdesc *var) {
547static void adjust_assign (LexState *ls, int nvars, int nexps, expdesc *e) { 547static void adjust_assign (LexState *ls, int nvars, int nexps, expdesc *e) {
548 FuncState *fs = ls->fs; 548 FuncState *fs = ls->fs;
549 int needed = nvars - nexps; /* extra values needed */ 549 int needed = nvars - nexps; /* extra values needed */
550 luaK_checkstack(fs, needed);
550 if (hasmultret(e->k)) { /* last expression has multiple returns? */ 551 if (hasmultret(e->k)) { /* last expression has multiple returns? */
551 int extra = needed + 1; /* discount last expression itself */ 552 int extra = needed + 1; /* discount last expression itself */
552 if (extra < 0) 553 if (extra < 0)