From d61b0c60287c38008d312ddd11724a15b1737f7b Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Thu, 26 May 2022 15:14:54 -0300 Subject: More checks and documentation for uses of EXTRA_STACK --- ldo.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'ldo.c') diff --git a/ldo.c b/ldo.c index 13498905..419b3db9 100644 --- a/ldo.c +++ b/ldo.c @@ -602,12 +602,17 @@ CallInfo *luaD_precall (lua_State *L, StkId func, int nresults) { ** Call a function (C or Lua) through C. 'inc' can be 1 (increment ** number of recursive invocations in the C stack) or nyci (the same ** plus increment number of non-yieldable calls). +** This function can be called with some use of EXTRA_STACK, so it should +** check the stack before doing anything else. 'luaD_precall' already +** does that. */ l_sinline void ccall (lua_State *L, StkId func, int nResults, int inc) { CallInfo *ci; L->nCcalls += inc; - if (l_unlikely(getCcalls(L) >= LUAI_MAXCCALLS)) + if (l_unlikely(getCcalls(L) >= LUAI_MAXCCALLS)) { + checkstackp(L, 0, func); /* free any use of EXTRA_STACK */ luaE_checkcstack(L); + } if ((ci = luaD_precall(L, func, nResults)) != NULL) { /* Lua function? */ ci->callstatus = CIST_FRESH; /* mark that it is a "fresh" execute */ luaV_execute(L, ci); /* call it */ -- cgit v1.2.3-55-g6feb