aboutsummaryrefslogtreecommitdiff
path: root/lvm.c
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 /lvm.c
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 'lvm.c')
-rw-r--r--lvm.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/lvm.c b/lvm.c
index 66d451b0..08681af1 100644
--- a/lvm.c
+++ b/lvm.c
@@ -1794,7 +1794,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
1794 ProtectNT(luaT_adjustvarargs(L, GETARG_A(i), ci, cl->p)); 1794 ProtectNT(luaT_adjustvarargs(L, GETARG_A(i), ci, cl->p));
1795 if (trap) { 1795 if (trap) {
1796 luaD_hookcall(L, ci); 1796 luaD_hookcall(L, ci);
1797 L->oldpc = pc + 1; /* next opcode will be seen as a "new" line */ 1797 L->oldpc = 1; /* next opcode will be seen as a "new" line */
1798 } 1798 }
1799 updatebase(ci); /* function has new base after adjustment */ 1799 updatebase(ci); /* function has new base after adjustment */
1800 vmbreak; 1800 vmbreak;