From a2195644d89812e5b157ce7bac35543e06db05e3 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Fri, 17 Jul 2020 11:01:05 -0300 Subject: Fixed bug: invalid 'oldpc' when returning to a function The field 'L->oldpc' is not always updated when control returns to a function; an invalid value can seg. fault when computing 'changedline'. (One example is an error in a finalizer; control can return to 'luaV_execute' without executing 'luaD_poscall'.) Instead of trying to fix all possible corner cases, it seems safer to be resilient to invalid values for 'oldpc'. Valid but wrong values at most cause an extra call to a line hook. --- lstate.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lstate.h') diff --git a/lstate.h b/lstate.h index 2e8bd6c4..0c545ec5 100644 --- a/lstate.h +++ b/lstate.h @@ -286,7 +286,6 @@ struct lua_State { StkId top; /* first free slot in the stack */ global_State *l_G; CallInfo *ci; /* call info for current function */ - const Instruction *oldpc; /* last pc traced */ StkId stack_last; /* last free slot in the stack */ StkId stack; /* stack base */ UpVal *openupval; /* list of open upvalues in this stack */ @@ -297,6 +296,7 @@ struct lua_State { volatile lua_Hook hook; ptrdiff_t errfunc; /* current error handling function (stack index) */ l_uint32 nCcalls; /* number of allowed nested C calls - 'nci' */ + int oldpc; /* last pc traced */ int stacksize; int basehookcount; int hookcount; -- cgit v1.2.3-55-g6feb