aboutsummaryrefslogtreecommitdiff
path: root/lstate.h
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2020-07-17 11:01:05 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2020-07-17 11:01:05 -0300
commita2195644d89812e5b157ce7bac35543e06db05e3 (patch)
tree878e4e64731fc598e8868b37888b7da4aa447dbb /lstate.h
parent1ecfbfa1a1debd2258decdf7c1954ac6f9761699 (diff)
downloadlua-a2195644d89812e5b157ce7bac35543e06db05e3.tar.gz
lua-a2195644d89812e5b157ce7bac35543e06db05e3.tar.bz2
lua-a2195644d89812e5b157ce7bac35543e06db05e3.zip
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.
Diffstat (limited to 'lstate.h')
-rw-r--r--lstate.h2
1 files changed, 1 insertions, 1 deletions
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 {
286 StkId top; /* first free slot in the stack */ 286 StkId top; /* first free slot in the stack */
287 global_State *l_G; 287 global_State *l_G;
288 CallInfo *ci; /* call info for current function */ 288 CallInfo *ci; /* call info for current function */
289 const Instruction *oldpc; /* last pc traced */
290 StkId stack_last; /* last free slot in the stack */ 289 StkId stack_last; /* last free slot in the stack */
291 StkId stack; /* stack base */ 290 StkId stack; /* stack base */
292 UpVal *openupval; /* list of open upvalues in this stack */ 291 UpVal *openupval; /* list of open upvalues in this stack */
@@ -297,6 +296,7 @@ struct lua_State {
297 volatile lua_Hook hook; 296 volatile lua_Hook hook;
298 ptrdiff_t errfunc; /* current error handling function (stack index) */ 297 ptrdiff_t errfunc; /* current error handling function (stack index) */
299 l_uint32 nCcalls; /* number of allowed nested C calls - 'nci' */ 298 l_uint32 nCcalls; /* number of allowed nested C calls - 'nci' */
299 int oldpc; /* last pc traced */
300 int stacksize; 300 int stacksize;
301 int basehookcount; 301 int basehookcount;
302 int hookcount; 302 int hookcount;