From e8deac5a41ffd644aaa78fda6d4bd5caa72cb077 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Wed, 10 Nov 2021 15:07:14 -0300 Subject: Avoid OP_VARARGPREP for active lines when building the table 'activelines' for a vararg function, this first instruction does not make the first line active. --- ldebug.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'ldebug.c') diff --git a/ldebug.c b/ldebug.c index dde4669e..30a28828 100644 --- a/ldebug.c +++ b/ldebug.c @@ -301,7 +301,14 @@ static void collectvalidlines (lua_State *L, Closure *f) { sethvalue2s(L, L->top, t); /* push it on stack */ api_incr_top(L); setbtvalue(&v); /* boolean 'true' to be the value of all indices */ - for (i = 0; i < p->sizelineinfo; i++) { /* for all instructions */ + if (!p->is_vararg) /* regular function? */ + i = 0; /* consider all instructions */ + else { /* vararg function */ + lua_assert(p->code[0] == OP_VARARGPREP); + currentline = nextline(p, currentline, 0); + i = 1; /* skip first instruction (OP_VARARGPREP) */ + } + for (; i < p->sizelineinfo; i++) { /* for each instruction */ currentline = nextline(p, currentline, i); /* get its line */ luaH_setint(L, t, currentline, &v); /* table[line] = true */ } -- cgit v1.2.3-55-g6feb