diff options
Diffstat (limited to 'libs/liblua/src/lstate.c')
-rw-r--r-- | libs/liblua/src/lstate.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/libs/liblua/src/lstate.c b/libs/liblua/src/lstate.c index b1b406ab15..ee0a1773cd 100644 --- a/libs/liblua/src/lstate.c +++ b/libs/liblua/src/lstate.c @@ -301,6 +301,7 @@ static void preinit_thread (lua_State *L, global_State *g) { L->openupval = NULL; L->status = LUA_OK; L->errfunc = 0; + L->oldpc = 0; } @@ -318,9 +319,10 @@ static void close_state (lua_State *L) { LUA_API lua_State *lua_newthread (lua_State *L) { - global_State *g = G(L); + global_State *g; lua_State *L1; lua_lock(L); + g = G(L); luaC_checkGC(L); /* create new thread */ L1 = &cast(LX *, luaM_newobject(L, LUA_TTHREAD, sizeof(LX)))->l; @@ -395,6 +397,7 @@ LUA_API lua_State *lua_newstate (lua_Alloc f, void *ud) { g->allgc = obj2gco(L); /* by now, only object is the main thread */ L->next = NULL; g->Cstacklimit = L->nCcalls = LUAI_MAXCSTACK + CSTACKERR; + incnny(L); /* main thread is always non yieldable */ g->frealloc = f; g->ud = ud; g->warnf = NULL; @@ -410,8 +413,8 @@ LUA_API lua_State *lua_newstate (lua_Alloc f, void *ud) { g->gckind = KGC_INC; g->gcemergency = 0; g->finobj = g->tobefnz = g->fixedgc = NULL; - g->survival = g->old = g->reallyold = NULL; - g->finobjsur = g->finobjold = g->finobjrold = NULL; + g->firstold1 = g->survival = g->old1 = g->reallyold = NULL; + g->finobjsur = g->finobjold1 = g->finobjrold = NULL; g->sweepgc = NULL; g->gray = g->grayagain = NULL; g->weak = g->ephemeron = g->allweak = NULL; @@ -436,11 +439,12 @@ LUA_API lua_State *lua_newstate (lua_Alloc f, void *ud) { LUA_API void lua_close (lua_State *L) { + if (!L) - return; + return; - L = G(L)->mainthread; /* only the main thread can be closed */ lua_lock(L); + L = G(L)->mainthread; /* only the main thread can be closed */ close_state(L); } |