diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2021-01-19 10:03:13 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2021-01-19 10:03:13 -0300 |
commit | 6ccd24eff58340c00db2877c4558a63c6b859442 (patch) | |
tree | 4c8f51657d8d1f4921846a23ba4b475db49fd837 /lstate.c | |
parent | d0f34d91373fa265d4445e456e4a10ce206c1559 (diff) | |
download | lua-6ccd24eff58340c00db2877c4558a63c6b859442.tar.gz lua-6ccd24eff58340c00db2877c4558a63c6b859442.tar.bz2 lua-6ccd24eff58340c00db2877c4558a63c6b859442.zip |
Simpler handling of errors when creating tbc variables
New field 'lua_State.ptbc' keeps to-be-closed variable until its
upvalue is created, so that it can be closed in case of a
memory-allocation error.
Diffstat (limited to 'lstate.c')
-rw-r--r-- | lstate.c | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -253,6 +253,7 @@ static void preinit_thread (lua_State *L, global_State *g) { | |||
253 | L->ci = NULL; | 253 | L->ci = NULL; |
254 | L->nci = 0; | 254 | L->nci = 0; |
255 | L->twups = L; /* thread has no upvalues */ | 255 | L->twups = L; /* thread has no upvalues */ |
256 | L->nCcalls = 0; | ||
256 | L->errorJmp = NULL; | 257 | L->errorJmp = NULL; |
257 | L->hook = NULL; | 258 | L->hook = NULL; |
258 | L->hookmask = 0; | 259 | L->hookmask = 0; |
@@ -263,6 +264,7 @@ static void preinit_thread (lua_State *L, global_State *g) { | |||
263 | L->status = LUA_OK; | 264 | L->status = LUA_OK; |
264 | L->errfunc = 0; | 265 | L->errfunc = 0; |
265 | L->oldpc = 0; | 266 | L->oldpc = 0; |
267 | L->ptbc = NULL; | ||
266 | } | 268 | } |
267 | 269 | ||
268 | 270 | ||
@@ -296,7 +298,6 @@ LUA_API lua_State *lua_newthread (lua_State *L) { | |||
296 | setthvalue2s(L, L->top, L1); | 298 | setthvalue2s(L, L->top, L1); |
297 | api_incr_top(L); | 299 | api_incr_top(L); |
298 | preinit_thread(L1, g); | 300 | preinit_thread(L1, g); |
299 | L1->nCcalls = 0; | ||
300 | L1->hookmask = L->hookmask; | 301 | L1->hookmask = L->hookmask; |
301 | L1->basehookcount = L->basehookcount; | 302 | L1->basehookcount = L->basehookcount; |
302 | L1->hook = L->hook; | 303 | L1->hook = L->hook; |
@@ -363,7 +364,6 @@ LUA_API lua_State *lua_newstate (lua_Alloc f, void *ud) { | |||
363 | preinit_thread(L, g); | 364 | preinit_thread(L, g); |
364 | g->allgc = obj2gco(L); /* by now, only object is the main thread */ | 365 | g->allgc = obj2gco(L); /* by now, only object is the main thread */ |
365 | L->next = NULL; | 366 | L->next = NULL; |
366 | L->nCcalls = 0; | ||
367 | incnny(L); /* main thread is always non yieldable */ | 367 | incnny(L); /* main thread is always non yieldable */ |
368 | g->frealloc = f; | 368 | g->frealloc = f; |
369 | g->ud = ud; | 369 | g->ud = ud; |