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.
This commit is contained in:
Roberto Ierusalimschy
2021-01-19 10:03:13 -03:00
parent d0f34d9137
commit 6ccd24eff5
6 changed files with 25 additions and 35 deletions

1
ldo.c
View File

@@ -163,6 +163,7 @@ static void correctstack (lua_State *L, StkId oldstack, StkId newstack) {
if (oldstack == newstack)
return; /* stack address did not change */
L->top = (L->top - oldstack) + newstack;
lua_assert(L->ptbc == NULL);
for (up = L->openupval; up != NULL; up = up->u.open.next)
up->v = s2v((uplevel(up) - oldstack) + newstack);
for (ci = L->ci; ci != NULL; ci = ci->previous) {