diff options
author | Mike Pall <mike> | 2010-04-23 17:42:25 +0200 |
---|---|---|
committer | Mike Pall <mike> | 2010-04-23 17:42:25 +0200 |
commit | 28a6284642c81c9d100011dad999f5467db31974 (patch) | |
tree | 6de4ed2c31346ed606a4390109514dbeec126c4e /src | |
parent | a6c52d80a21b53b7e43b77d1b3820770bc204b08 (diff) | |
download | luajit-28a6284642c81c9d100011dad999f5467db31974.tar.gz luajit-28a6284642c81c9d100011dad999f5467db31974.tar.bz2 luajit-28a6284642c81c9d100011dad999f5467db31974.zip |
Add assertions to guard against using lua_*call on dead coroutines.
Diffstat (limited to 'src')
-rw-r--r-- | src/lj_api.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/lj_api.c b/src/lj_api.c index aac3b4c9..ed4238a9 100644 --- a/src/lj_api.c +++ b/src/lj_api.c | |||
@@ -997,6 +997,7 @@ LUA_API const char *lua_setupvalue(lua_State *L, int idx, int n) | |||
997 | 997 | ||
998 | LUA_API void lua_call(lua_State *L, int nargs, int nresults) | 998 | LUA_API void lua_call(lua_State *L, int nargs, int nresults) |
999 | { | 999 | { |
1000 | api_check(L, L->status == 0 || L->status == LUA_ERRERR); | ||
1000 | api_checknelems(L, nargs+1); | 1001 | api_checknelems(L, nargs+1); |
1001 | lj_vm_call(L, L->top - nargs, nresults+1); | 1002 | lj_vm_call(L, L->top - nargs, nresults+1); |
1002 | } | 1003 | } |
@@ -1007,6 +1008,7 @@ LUA_API int lua_pcall(lua_State *L, int nargs, int nresults, int errfunc) | |||
1007 | uint8_t oldh = hook_save(g); | 1008 | uint8_t oldh = hook_save(g); |
1008 | ptrdiff_t ef; | 1009 | ptrdiff_t ef; |
1009 | int status; | 1010 | int status; |
1011 | api_check(L, L->status == 0 || L->status == LUA_ERRERR); | ||
1010 | api_checknelems(L, nargs+1); | 1012 | api_checknelems(L, nargs+1); |
1011 | if (errfunc == 0) { | 1013 | if (errfunc == 0) { |
1012 | ef = 0; | 1014 | ef = 0; |
@@ -1022,8 +1024,7 @@ LUA_API int lua_pcall(lua_State *L, int nargs, int nresults, int errfunc) | |||
1022 | 1024 | ||
1023 | static TValue *cpcall(lua_State *L, lua_CFunction func, void *ud) | 1025 | static TValue *cpcall(lua_State *L, lua_CFunction func, void *ud) |
1024 | { | 1026 | { |
1025 | GCfunc *fn; | 1027 | GCfunc *fn = lj_func_newC(L, 0, getcurrenv(L)); |
1026 | fn = lj_func_newC(L, 0, getcurrenv(L)); | ||
1027 | fn->c.f = func; | 1028 | fn->c.f = func; |
1028 | setfuncV(L, L->top, fn); | 1029 | setfuncV(L, L->top, fn); |
1029 | setlightudV(L->top+1, checklightudptr(L, ud)); | 1030 | setlightudV(L->top+1, checklightudptr(L, ud)); |
@@ -1036,7 +1037,9 @@ LUA_API int lua_cpcall(lua_State *L, lua_CFunction func, void *ud) | |||
1036 | { | 1037 | { |
1037 | global_State *g = G(L); | 1038 | global_State *g = G(L); |
1038 | uint8_t oldh = hook_save(g); | 1039 | uint8_t oldh = hook_save(g); |
1039 | int status = lj_vm_cpcall(L, func, ud, cpcall); | 1040 | int status; |
1041 | api_check(L, L->status == 0 || L->status == LUA_ERRERR); | ||
1042 | status = lj_vm_cpcall(L, func, ud, cpcall); | ||
1040 | if (status) hook_restore(g, oldh); | 1043 | if (status) hook_restore(g, oldh); |
1041 | return status; | 1044 | return status; |
1042 | } | 1045 | } |