aboutsummaryrefslogtreecommitdiff
path: root/lcorolib.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2021-11-08 11:55:25 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2021-11-08 11:55:25 -0300
commitbfbff3703edae789fa5efa9bf174f8e7cff4ded8 (patch)
tree5e8466f78f52b5d53691f800354a3aed313d11a9 /lcorolib.c
parent74d99057a5146755e737c479850f87fd0e3b6868 (diff)
downloadlua-bfbff3703edae789fa5efa9bf174f8e7cff4ded8.tar.gz
lua-bfbff3703edae789fa5efa9bf174f8e7cff4ded8.tar.bz2
lua-bfbff3703edae789fa5efa9bf174f8e7cff4ded8.zip
Bug: Wrong status in coroutine during reset
When closing variables during 'coroutine.close' or 'lua_resetthread', the status of a coroutine must be set to LUA_OK; a coroutine should not run with any other status. (See assertion in 'lua_callk'.) After the reset, the status should be kept as normal, as any error was already reported.
Diffstat (limited to 'lcorolib.c')
-rw-r--r--lcorolib.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/lcorolib.c b/lcorolib.c
index fedbebec..785a1e81 100644
--- a/lcorolib.c
+++ b/lcorolib.c
@@ -78,7 +78,7 @@ static int luaB_auxwrap (lua_State *L) {
78 if (stat != LUA_OK && stat != LUA_YIELD) { /* error in the coroutine? */ 78 if (stat != LUA_OK && stat != LUA_YIELD) { /* error in the coroutine? */
79 stat = lua_resetthread(co); /* close its tbc variables */ 79 stat = lua_resetthread(co); /* close its tbc variables */
80 lua_assert(stat != LUA_OK); 80 lua_assert(stat != LUA_OK);
81 lua_xmove(co, L, 1); /* copy error message */ 81 lua_xmove(co, L, 1); /* move error message to the caller */
82 } 82 }
83 if (stat != LUA_ERRMEM && /* not a memory error and ... */ 83 if (stat != LUA_ERRMEM && /* not a memory error and ... */
84 lua_type(L, -1) == LUA_TSTRING) { /* ... error object is a string? */ 84 lua_type(L, -1) == LUA_TSTRING) { /* ... error object is a string? */
@@ -179,7 +179,7 @@ static int luaB_close (lua_State *L) {
179 } 179 }
180 else { 180 else {
181 lua_pushboolean(L, 0); 181 lua_pushboolean(L, 0);
182 lua_xmove(co, L, 1); /* copy error message */ 182 lua_xmove(co, L, 1); /* move error message */
183 return 2; 183 return 2;
184 } 184 }
185 } 185 }