Cleaner handling of errors in '__close' metamethods

Instead of protecting each individual metamethod call, protect the
entire call to 'luaF_close'.
This commit is contained in:
Roberto Ierusalimschy
2020-12-28 11:40:30 -03:00
parent 0ceada8da9
commit 7af27ef59d
7 changed files with 80 additions and 75 deletions

2
lapi.c
View File

@@ -188,7 +188,7 @@ LUA_API void lua_settop (lua_State *L, int idx) {
diff = idx + 1; /* will "subtract" index (as it is negative) */
}
if (diff < 0 && hastocloseCfunc(ci->nresults))
luaF_close(L, L->top + diff, LUA_OK);
luaF_close(L, L->top + diff, CLOSEKTOP);
L->top += diff; /* correct top only after closing any upvalue */
lua_unlock(L);
}