From 6cb8e241f7d8bcd933add9bf6e460d9ba81df12e Mon Sep 17 00:00:00 2001 From: Paul Kulchenko Date: Thu, 12 Aug 2021 20:58:15 -0700 Subject: [PATCH] Update redbean Lua to check there is enough stack to use --- tool/net/redbean.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tool/net/redbean.c b/tool/net/redbean.c index bd33d399d..6861ede90 100644 --- a/tool/net/redbean.c +++ b/tool/net/redbean.c @@ -1080,6 +1080,8 @@ static int LuaCallWithTrace(lua_State *L, int nargs, int nres) { } else { // move results to the main stack lua_xmove(co, L, nresults); + // make sure the stack has enough space to grow + luaL_checkstack(L, nres - nresults, NULL); // grow the stack in case returned fewer results // than the caller expects, as lua_resume // doesn't adjust the stack for needed results