diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2024-07-18 14:44:40 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2024-07-18 14:44:40 -0300 |
commit | a546138d158d79d44b2c5b42630be00d306f4e7c (patch) | |
tree | 8d2410921dc1af4dc8e7d19b21d3f313bcc812b4 /lcode.c | |
parent | cd4de92762434e6ed0e6c207d56d365300396dd8 (diff) | |
download | lua-a546138d158d79d44b2c5b42630be00d306f4e7c.tar.gz lua-a546138d158d79d44b2c5b42630be00d306f4e7c.tar.bz2 lua-a546138d158d79d44b2c5b42630be00d306f4e7c.zip |
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.
Diffstat (limited to 'lcode.c')
-rw-r--r-- | lcode.c | 2 |
1 files changed, 2 insertions, 0 deletions
@@ -724,6 +724,8 @@ static void const2exp (TValue *v, expdesc *e) { | |||
724 | */ | 724 | */ |
725 | void luaK_setreturns (FuncState *fs, expdesc *e, int nresults) { | 725 | void luaK_setreturns (FuncState *fs, expdesc *e, int nresults) { |
726 | Instruction *pc = &getinstruction(fs, e); | 726 | Instruction *pc = &getinstruction(fs, e); |
727 | if (nresults + 1 > MAXARG_C) | ||
728 | luaX_syntaxerror(fs->ls, "too many multiple results"); | ||
727 | if (e->k == VCALL) /* expression is an open function call? */ | 729 | if (e->k == VCALL) /* expression is an open function call? */ |
728 | SETARG_C(*pc, nresults + 1); | 730 | SETARG_C(*pc, nresults + 1); |
729 | else { | 731 | else { |