Avoid any code before locks in the API

For consistency in the C API, avoid any initializations before
callling lua_lock.
This commit is contained in:
Roberto Ierusalimschy
2020-07-06 14:06:47 -03:00
parent d39ea8b3ce
commit 314c6057b7
3 changed files with 22 additions and 12 deletions

3
ldo.c
View File

@@ -705,9 +705,10 @@ LUA_API int lua_isyieldable (lua_State *L) {
LUA_API int lua_yieldk (lua_State *L, int nresults, lua_KContext ctx,
lua_KFunction k) {
CallInfo *ci = L->ci;
CallInfo *ci;
luai_userstateyield(L, nresults);
lua_lock(L);
ci = L->ci;
api_checknelems(L, nresults);
if (unlikely(!yieldable(L))) {
if (L != G(L)->mainthread)