Finalizers must be callable

Non-function __gc metamethods are not ignored; if present, the
metamethod will be called even if it is not a function.
This commit is contained in:
Roberto Ierusalimschy
2019-03-14 15:53:42 -03:00
parent b56d4e570a
commit 8fa4f1380b
2 changed files with 20 additions and 5 deletions

2
lgc.c
View File

@@ -832,7 +832,7 @@ static void GCTM (lua_State *L) {
lua_assert(!g->gcemergency);
setgcovalue(L, &v, udata2finalize(g));
tm = luaT_gettmbyobj(L, &v, TM_GC);
if (ttisfunction(tm)) { /* is the finalizer a function? */
if (!notm(tm)) { /* is there a finalizer? */
int status;
lu_byte oldah = L->allowhook;
int running = g->gcrunning;