diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2010-04-19 14:40:13 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2010-04-19 14:40:13 -0300 |
commit | 4db6f20770ff3953a4e7472116e9158d4d584d2c (patch) | |
tree | d29547858619d1c3973a5a4c3599b993793798b2 /lstate.c | |
parent | cca71912e6c884c7a2fcf45c19d15e5d69810c97 (diff) | |
download | lua-4db6f20770ff3953a4e7472116e9158d4d584d2c.tar.gz lua-4db6f20770ff3953a4e7472116e9158d4d584d2c.tar.bz2 lua-4db6f20770ff3953a4e7472116e9158d4d584d2c.zip |
ensure that 'luai_userstatethread' is always called (even if
'stack_init' throws a memory error)
Diffstat (limited to 'lstate.c')
-rw-r--r-- | lstate.c | 9 |
1 files changed, 4 insertions, 5 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lstate.c,v 2.80 2010/04/14 15:14:21 roberto Exp roberto $ | 2 | ** $Id: lstate.c,v 2.81 2010/04/19 16:34:46 roberto Exp roberto $ |
3 | ** Global State | 3 | ** Global State |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -192,14 +192,13 @@ LUA_API lua_State *lua_newthread (lua_State *L) { | |||
192 | setthvalue(L, L->top, L1); | 192 | setthvalue(L, L->top, L1); |
193 | api_incr_top(L); | 193 | api_incr_top(L); |
194 | preinit_state(L1, G(L)); | 194 | preinit_state(L1, G(L)); |
195 | stack_init(L1, L); /* init stack */ | ||
196 | L1->hookmask = L->hookmask; | 195 | L1->hookmask = L->hookmask; |
197 | L1->basehookcount = L->basehookcount; | 196 | L1->basehookcount = L->basehookcount; |
198 | L1->hook = L->hook; | 197 | L1->hook = L->hook; |
199 | resethookcount(L1); | 198 | resethookcount(L1); |
200 | lua_assert(iswhite(obj2gco(L1))); | ||
201 | lua_unlock(L); | ||
202 | luai_userstatethread(L, L1); | 199 | luai_userstatethread(L, L1); |
200 | stack_init(L1, L); /* init stack */ | ||
201 | lua_unlock(L); | ||
203 | return L1; | 202 | return L1; |
204 | } | 203 | } |
205 | 204 | ||
@@ -208,7 +207,7 @@ void luaE_freethread (lua_State *L, lua_State *L1) { | |||
208 | LX *l = fromstate(L1); | 207 | LX *l = fromstate(L1); |
209 | luaF_close(L1, L1->stack); /* close all upvalues for this thread */ | 208 | luaF_close(L1, L1->stack); /* close all upvalues for this thread */ |
210 | lua_assert(L1->openupval == NULL); | 209 | lua_assert(L1->openupval == NULL); |
211 | luai_userstatefree(L1); | 210 | luai_userstatefree(L, L1); |
212 | freestack(L1); | 211 | freestack(L1); |
213 | luaM_free(L, l); | 212 | luaM_free(L, l); |
214 | } | 213 | } |