aboutsummaryrefslogtreecommitdiff
path: root/lapi.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2024-07-18 14:44:40 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2024-07-18 14:44:40 -0300
commita546138d158d79d44b2c5b42630be00d306f4e7c (patch)
tree8d2410921dc1af4dc8e7d19b21d3f313bcc812b4 /lapi.c
parentcd4de92762434e6ed0e6c207d56d365300396dd8 (diff)
downloadlua-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 'lapi.c')
-rw-r--r--lapi.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/lapi.c b/lapi.c
index f00bd53f..dbd291d7 100644
--- a/lapi.c
+++ b/lapi.c
@@ -1022,10 +1022,15 @@ LUA_API int lua_setiuservalue (lua_State *L, int idx, int n) {
1022*/ 1022*/
1023 1023
1024 1024
1025#define MAXRESULTS 250
1026
1027
1025#define checkresults(L,na,nr) \ 1028#define checkresults(L,na,nr) \
1026 api_check(L, (nr) == LUA_MULTRET \ 1029 (api_check(L, (nr) == LUA_MULTRET \
1027 || (L->ci->top.p - L->top.p >= (nr) - (na)), \ 1030 || (L->ci->top.p - L->top.p >= (nr) - (na)), \
1028 "results from function overflow current stack size") 1031 "results from function overflow current stack size"), \
1032 api_check(L, LUA_MULTRET <= (nr) && (nr) <= MAXRESULTS, \
1033 "invalid number of results"))
1029 1034
1030 1035
1031LUA_API void lua_callk (lua_State *L, int nargs, int nresults, 1036LUA_API void lua_callk (lua_State *L, int nargs, int nresults,