diff options
| author | Roberto I <roberto@inf.puc-rio.br> | 2025-10-10 13:22:19 -0300 |
|---|---|---|
| committer | Roberto I <roberto@inf.puc-rio.br> | 2025-10-10 13:22:19 -0300 |
| commit | 3347c9d32d4d91b6139bff475c78cf0c4796e2a7 (patch) | |
| tree | 008f1f82a5481149ce07328a188b72b535409f84 /lparser.c | |
| parent | 25c54fe60e22d05cdfaa48c64372d354efa59547 (diff) | |
| download | lua-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 'lparser.c')
| -rw-r--r-- | lparser.c | 1 |
1 files changed, 1 insertions, 0 deletions
| @@ -547,6 +547,7 @@ static void singlevar (LexState *ls, expdesc *var) { | |||
| 547 | static void adjust_assign (LexState *ls, int nvars, int nexps, expdesc *e) { | 547 | static 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) |
