From 94a40bb238092e73f3dc0c3626911a7efa997c22 Mon Sep 17 00:00:00 2001 From: Mike Pall Date: Thu, 23 Sep 2021 19:07:30 +0200 Subject: [PATCH] FFI: Ensure returned string is alive in ffi.typeinfo(). Reported by zhuizhuhaomeng. --- src/lib_ffi.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lib_ffi.c b/src/lib_ffi.c index a29014e5..b4321048 100644 --- a/src/lib_ffi.c +++ b/src/lib_ffi.c @@ -573,6 +573,7 @@ LJLIB_CF(ffi_typeinfo) setintV(lj_tab_setstr(L, t, lj_str_newlit(L, "sib")), (int32_t)ct->sib); if (gcref(ct->name)) { GCstr *s = gco2str(gcref(ct->name)); + if (isdead(G(L), obj2gco(s))) flipwhite(obj2gco(s)); setstrV(L, lj_tab_setstr(L, t, lj_str_newlit(L, "name")), s); } lj_gc_check(L);