From f9e35627ed26dff4114a1d01ff113d8b4cc91ab5 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Wed, 26 Feb 2025 11:31:10 -0300 Subject: 'lua_State.nci' must be an integer Lua can easily overflow an unsigned short counting nested calls. (The limit to this value is the maximum stack size, LUAI_MAXSTACK, which is currently 1e6.) --- lstate.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lstate.h') diff --git a/lstate.h b/lstate.h index 050fc35f..f841c232 100644 --- a/lstate.h +++ b/lstate.h @@ -290,7 +290,6 @@ struct lua_State { CommonHeader; lu_byte allowhook; TStatus status; - unsigned short nci; /* number of items in 'ci' list */ StkIdRel top; /* first free slot in the stack */ struct global_State *l_G; CallInfo *ci; /* call info for current function */ @@ -306,6 +305,7 @@ struct lua_State { ptrdiff_t errfunc; /* current error handling function (stack index) */ l_uint32 nCcalls; /* number of nested non-yieldable or C calls */ int oldpc; /* last pc traced */ + int nci; /* number of items in 'ci' list */ int basehookcount; int hookcount; volatile l_signalT hookmask; -- cgit v1.2.3-55-g6feb