From 84a390632311637ac57666f09cd7211c8a7e0a0e Mon Sep 17 00:00:00 2001 From: takase1121 <20792268+takase1121@users.noreply.github.com> Date: Fri, 24 Dec 2021 15:04:52 +0800 Subject: [PATCH] fix FontGroup __gc method --- src/api/renderer.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/api/renderer.c b/src/api/renderer.c index bd001cdf..0fc21707 100644 --- a/src/api/renderer.c +++ b/src/api/renderer.c @@ -92,7 +92,7 @@ static int f_font_copy(lua_State *L) { return 1; } -static int f_font_group(lua_State* L) { +static int f_font_group(lua_State* L) { luaL_checktype(L, 1, LUA_TTABLE); luaL_setmetatable(L, API_TYPE_FONT); return 1; @@ -106,8 +106,10 @@ static int f_font_set_tab_size(lua_State *L) { } static int f_font_gc(lua_State *L) { + if (lua_istable(L, 1)) return 0; // do not run if its FontGroup RenFont** self = luaL_checkudata(L, 1, API_TYPE_FONT); ren_font_free(*self); + return 0; }