diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2018-01-10 10:02:35 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2018-01-10 10:02:35 -0200 |
commit | 728ff9459579894ef7fd861c90be6247831799be (patch) | |
tree | 93dd400e31718017f454cada18143219c3e18dcc | |
parent | ad960095bfc10e9b7172ac8bd6ae785d798b850f (diff) | |
download | lua-728ff9459579894ef7fd861c90be6247831799be.tar.gz lua-728ff9459579894ef7fd861c90be6247831799be.tar.bz2 lua-728ff9459579894ef7fd861c90be6247831799be.zip |
error handler in protected calls must be a function
-rw-r--r-- | lapi.c | 3 | ||||
-rw-r--r-- | ldebug.c | 4 |
2 files changed, 4 insertions, 3 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lapi.c,v 2.278 2017/12/06 18:08:03 roberto Exp roberto $ | 2 | ** $Id: lapi.c,v 2.279 2017/12/08 17:28:25 roberto Exp roberto $ |
3 | ** Lua API | 3 | ** Lua API |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -980,6 +980,7 @@ LUA_API int lua_pcallk (lua_State *L, int nargs, int nresults, int errfunc, | |||
980 | func = 0; | 980 | func = 0; |
981 | else { | 981 | else { |
982 | StkId o = index2stack(L, errfunc); | 982 | StkId o = index2stack(L, errfunc); |
983 | api_check(L, ttisfunction(s2v(o)), "error handler must be a function"); | ||
983 | func = savestack(L, o); | 984 | func = savestack(L, o); |
984 | } | 985 | } |
985 | c.func = L->top - (nargs+1); /* function to be called */ | 986 | c.func = L->top - (nargs+1); /* function to be called */ |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ldebug.c,v 2.150 2017/12/20 14:58:05 roberto Exp roberto $ | 2 | ** $Id: ldebug.c,v 2.151 2017/12/28 15:42:57 roberto Exp roberto $ |
3 | ** Debug Interface | 3 | ** Debug Interface |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -722,10 +722,10 @@ const char *luaG_addinfo (lua_State *L, const char *msg, TString *src, | |||
722 | l_noret luaG_errormsg (lua_State *L) { | 722 | l_noret luaG_errormsg (lua_State *L) { |
723 | if (L->errfunc != 0) { /* is there an error handling function? */ | 723 | if (L->errfunc != 0) { /* is there an error handling function? */ |
724 | StkId errfunc = restorestack(L, L->errfunc); | 724 | StkId errfunc = restorestack(L, L->errfunc); |
725 | lua_assert(ttisfunction(s2v(errfunc))); | ||
725 | setobjs2s(L, L->top, L->top - 1); /* move argument */ | 726 | setobjs2s(L, L->top, L->top - 1); /* move argument */ |
726 | setobjs2s(L, L->top - 1, errfunc); /* push function */ | 727 | setobjs2s(L, L->top - 1, errfunc); /* push function */ |
727 | L->top++; /* assume EXTRA_STACK */ | 728 | L->top++; /* assume EXTRA_STACK */ |
728 | luaE_incCcalls(L); | ||
729 | luaD_callnoyield(L, L->top - 2, 1); /* call it */ | 729 | luaD_callnoyield(L, L->top - 2, 1); /* call it */ |
730 | } | 730 | } |
731 | luaD_throw(L, LUA_ERRRUN); | 731 | luaD_throw(L, LUA_ERRRUN); |