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. --- ldebug.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'ldebug.h') diff --git a/ldebug.h b/ldebug.h index 1fe0efab..a0a58486 100644 --- a/ldebug.h +++ b/ldebug.h @@ -13,6 +13,11 @@ #define pcRel(pc, p) (cast_int((pc) - (p)->code) - 1) + +/* Active Lua function (given call info) */ +#define ci_func(ci) (clLvalue(s2v((ci)->func))) + + #define resethookcount(L) (L->hookcount = L->basehookcount) /* -- cgit v1.2.3-55-g6feb