aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Pall <mike>2011-03-09 22:39:17 +0100
committerMike Pall <mike>2011-03-09 22:39:17 +0100
commit30cc4d3bba27d5bd1415098a53f383b7bbe0a0fa (patch)
treec011ab370538e7f0a92074af5ceee0b8302c48f2 /src
parent0125ee821188fea1778a70fbd1f9b1dc6c2a1e2a (diff)
downloadluajit-30cc4d3bba27d5bd1415098a53f383b7bbe0a0fa.tar.gz
luajit-30cc4d3bba27d5bd1415098a53f383b7bbe0a0fa.tar.bz2
luajit-30cc4d3bba27d5bd1415098a53f383b7bbe0a0fa.zip
Fix handling of err_loc() within cpcall frames.
Diffstat (limited to 'src')
-rw-r--r--src/lj_err.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/lj_err.c b/src/lj_err.c
index 2503c218..7f9db600 100644
--- a/src/lj_err.c
+++ b/src/lj_err.c
@@ -87,9 +87,10 @@ static BCPos currentpc(lua_State *L, GCfunc *fn, cTValue *nextframe)
87 if (!isluafunc(fn)) { /* Cannot derive a PC for non-Lua functions. */ 87 if (!isluafunc(fn)) { /* Cannot derive a PC for non-Lua functions. */
88 return ~(BCPos)0; 88 return ~(BCPos)0;
89 } else if (nextframe == NULL) { /* Lua function on top. */ 89 } else if (nextframe == NULL) { /* Lua function on top. */
90 if (L->cframe == NULL) 90 void *cf = cframe_raw(L->cframe);
91 if (cf == NULL || (char *)cframe_pc(cf) == (char *)cframe_L(cf))
91 return ~(BCPos)0; 92 return ~(BCPos)0;
92 ins = cframe_Lpc(L); /* Only happens during error/hook handling. */ 93 ins = cframe_pc(cf); /* Only happens during error/hook handling. */
93 } else { 94 } else {
94 if (frame_islua(nextframe)) { 95 if (frame_islua(nextframe)) {
95 ins = frame_pc(nextframe); 96 ins = frame_pc(nextframe);
@@ -815,9 +816,11 @@ LJ_NOINLINE static void err_loc(lua_State *L, const char *msg,
815 if (isluafunc(fn)) { 816 if (isluafunc(fn)) {
816 char buff[LUA_IDSIZE]; 817 char buff[LUA_IDSIZE];
817 BCLine line = currentline(L, fn, nextframe); 818 BCLine line = currentline(L, fn, nextframe);
818 err_chunkid(buff, strdata(proto_chunkname(funcproto(fn)))); 819 if (line >= 0) {
819 lj_str_pushf(L, "%s:%d: %s", buff, line, msg); 820 err_chunkid(buff, strdata(proto_chunkname(funcproto(fn))));
820 return; 821 lj_str_pushf(L, "%s:%d: %s", buff, line, msg);
822 return;
823 }
821 } 824 }
822 } 825 }
823 lj_str_pushf(L, "%s", msg); 826 lj_str_pushf(L, "%s", msg);