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.
This commit is contained in:
Roberto Ierusalimschy 2024-07-18 14:44:40 -03:00
parent cd4de92762
commit a546138d15
3 changed files with 17 additions and 4 deletions

View file

@ -724,6 +724,8 @@ static void const2exp (TValue *v, expdesc *e) {
*/
void luaK_setreturns (FuncState *fs, expdesc *e, int nresults) {
Instruction *pc = &getinstruction(fs, e);
if (nresults + 1 > MAXARG_C)
luaX_syntaxerror(fs->ls, "too many multiple results");
if (e->k == VCALL) /* expression is an open function call? */
SETARG_C(*pc, nresults + 1);
else {