Explicit limit for number of results in a call · lua/lua@a546138 · GitHub
Skip to content

Commit a546138

Browse files
committed
Explicit limit for number of results in a call
The parameter 'nresults' in 'lua_call' and similar functions has a limit of 250. It already had an undocumented (and unchecked) limit of SHRT_MAX, but it is seldom larger than 2.
1 parent cd4de92 commit a546138

3 files changed

Lines changed: 17 additions & 4 deletions

File tree

‎lapi.c‎

Lines changed: 7 additions & 2 deletions

‎lcode.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -724,6 +724,8 @@ static void const2exp (TValue *v, expdesc *e) {
724724
*/
725725
void luaK_setreturns (FuncState *fs, expdesc *e, int nresults) {
726726
Instruction *pc = &getinstruction(fs, e);
727+
if (nresults + 1 > MAXARG_C)
728+
luaX_syntaxerror(fs->ls, "too many multiple results");
727729
if (e->k == VCALL) /* expression is an open function call? */
728730
SETARG_C(*pc, nresults + 1);
729731
else {

‎manual/manual.of‎

Lines changed: 8 additions & 2 deletions

0 commit comments

Comments
 (0)