summaryrefslogtreecommitdiff
path: root/lstate.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 /lstate.c
parent74d99057a5146755e737c479850f87fd0e3b6868 (diff)
downloadlua-github-bfbff3703edae789fa5efa9bf174f8e7cff4ded8.tar.gz
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 'lstate.c')
-rw-r--r--lstate.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/lstate.c b/lstate.c
index bfc59026..5cb0847c 100644
--- a/lstate.c
+++ b/lstate.c
@@ -166,7 +166,7 @@ void luaE_checkcstack (lua_State *L) {
if (getCcalls(L) == LUAI_MAXCCALLS)
luaG_runerror(L, "C stack overflow");
else if (getCcalls(L) >= (LUAI_MAXCCALLS / 10 * 11))
- luaD_throw(L, LUA_ERRERR); /* error while handing stack error */
+ luaD_throw(L, LUA_ERRERR); /* error while handling stack error */
}
@@ -330,13 +330,13 @@ int luaE_resetthread (lua_State *L, int status) {
ci->callstatus = CIST_C;
if (status == LUA_YIELD)
status = LUA_OK;
+ L->status = LUA_OK; /* so it can run __close metamethods */
status = luaD_closeprotected(L, 1, status);
if (status != LUA_OK) /* errors? */
luaD_seterrorobj(L, status, L->stack + 1);
else
L->top = L->stack + 1;
ci->top = L->top + LUA_MINSTACK;
- L->status = cast_byte(status);
luaD_reallocstack(L, cast_int(ci->top - L->stack), 0);
return status;
}