aboutsummaryrefslogtreecommitdiff
path: root/src/lj_snap.c
diff options
context:
space:
mode:
authorMike Pall <mike>2025-05-28 21:02:31 +0200
committerMike Pall <mike>2025-05-28 21:02:31 +0200
commitcd4af8ad80bb6430ad2e547f7af236268c9be7d9 (patch)
tree60cb40dd5a5d3cbec90b3563c9c750923d3542d8 /src/lj_snap.c
parent9c8eb7cfe10ef5939d9b358a0bd805a610818ba5 (diff)
downloadluajit-cd4af8ad80bb6430ad2e547f7af236268c9be7d9.tar.gz
luajit-cd4af8ad80bb6430ad2e547f7af236268c9be7d9.tar.bz2
luajit-cd4af8ad80bb6430ad2e547f7af236268c9be7d9.zip
Avoid out-of-range PC for stack overflow error from snapshot restore.
Reported by Sergey Kaplun. #1359
Diffstat (limited to 'src/lj_snap.c')
-rw-r--r--src/lj_snap.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/lj_snap.c b/src/lj_snap.c
index 82ab6983..54260021 100644
--- a/src/lj_snap.c
+++ b/src/lj_snap.c
@@ -872,8 +872,10 @@ const BCIns *lj_snap_restore(jit_State *J, void *exptr)
872 const BCIns *pc = snap_pc(map[nent]); 872 const BCIns *pc = snap_pc(map[nent]);
873 lua_State *L = J->L; 873 lua_State *L = J->L;
874 874
875 /* Set interpreter PC to the next PC to get correct error messages. */ 875 /* Set interpreter PC to the next PC to get correct error messages.
876 setcframe_pc(L->cframe, pc+1); 876 ** But not for returns or tail calls, since pc+1 may be out-of-range.
877 */
878 setcframe_pc(L->cframe, bc_isret_or_tail(bc_op(*pc)) ? pc : pc+1);
877 setcframe_pc(cframe_raw(cframe_prev(L->cframe)), pc); 879 setcframe_pc(cframe_raw(cframe_prev(L->cframe)), pc);
878 880
879 /* Make sure the stack is big enough for the slots from the snapshot. */ 881 /* Make sure the stack is big enough for the slots from the snapshot. */