diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/lj_err.c | 13 |
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); |