From 8c596dc1efa8a1267c222b168a4de9c8ba254760 Mon Sep 17 00:00:00 2001 From: Li Jin Date: Sat, 18 Jul 2020 16:45:50 +0800 Subject: fix issue for using return statement with export. --- src/lua/lcorolib.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/lua/lcorolib.c') diff --git a/src/lua/lcorolib.c b/src/lua/lcorolib.c index 7d6e585..c165031 100644 --- a/src/lua/lcorolib.c +++ b/src/lua/lcorolib.c @@ -73,11 +73,12 @@ static int luaB_coresume (lua_State *L) { static int luaB_auxwrap (lua_State *L) { lua_State *co = lua_tothread(L, lua_upvalueindex(1)); int r = auxresume(L, co, lua_gettop(L)); - if (r < 0) { + if (r < 0) { /* error? */ int stat = lua_status(co); - if (stat != LUA_OK && stat != LUA_YIELD) - lua_resetthread(co); /* close variables in case of errors */ - if (lua_type(L, -1) == LUA_TSTRING) { /* error object is a string? */ + if (stat != LUA_OK && stat != LUA_YIELD) /* error in the coroutine? */ + lua_resetthread(co); /* close its tbc variables */ + if (stat != LUA_ERRMEM && /* not a memory error and ... */ + lua_type(L, -1) == LUA_TSTRING) { /* ... error object is a string? */ luaL_where(L, 1); /* add extra info, if available */ lua_insert(L, -2); lua_concat(L, 2); -- cgit v1.2.3-55-g6feb