From 4db6f20770ff3953a4e7472116e9158d4d584d2c Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Mon, 19 Apr 2010 14:40:13 -0300 Subject: ensure that 'luai_userstatethread' is always called (even if 'stack_init' throws a memory error) --- lstate.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'lstate.c') diff --git a/lstate.c b/lstate.c index 462b7db8..c3aaeaf5 100644 --- a/lstate.c +++ b/lstate.c @@ -1,5 +1,5 @@ /* -** $Id: lstate.c,v 2.80 2010/04/14 15:14:21 roberto Exp roberto $ +** $Id: lstate.c,v 2.81 2010/04/19 16:34:46 roberto Exp roberto $ ** Global State ** See Copyright Notice in lua.h */ @@ -192,14 +192,13 @@ LUA_API lua_State *lua_newthread (lua_State *L) { setthvalue(L, L->top, L1); api_incr_top(L); preinit_state(L1, G(L)); - stack_init(L1, L); /* init stack */ L1->hookmask = L->hookmask; L1->basehookcount = L->basehookcount; L1->hook = L->hook; resethookcount(L1); - lua_assert(iswhite(obj2gco(L1))); - lua_unlock(L); luai_userstatethread(L, L1); + stack_init(L1, L); /* init stack */ + lua_unlock(L); return L1; } @@ -208,7 +207,7 @@ void luaE_freethread (lua_State *L, lua_State *L1) { LX *l = fromstate(L1); luaF_close(L1, L1->stack); /* close all upvalues for this thread */ lua_assert(L1->openupval == NULL); - luai_userstatefree(L1); + luai_userstatefree(L, L1); freestack(L1); luaM_free(L, l); } -- cgit v1.2.3-55-g6feb