From b87ec06708b906cd5bd22b3852d14d531c8e5c21 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Astor?= Date: Wed, 27 Apr 2022 11:33:00 +0200 Subject: [PATCH] :art: handle ref objects in closures --- src/vm/closure.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/vm/closure.c b/src/vm/closure.c index 910e6331..8d888293 100644 --- a/src/vm/closure.c +++ b/src/vm/closure.c @@ -19,9 +19,12 @@ ANN Closure *new_closure(MemPool mp, const m_uint sz) { ANN void free_closure(Closure *a, const Gwion gwion) { const Map m = &a->m; - for (m_uint i = 0; i < map_size(m); ++i) - compound_release(gwion->vm->cleaner_shred, (Type)VKEY(m, i), - a->data + VVAL(m, i)); + for (m_uint i = 0; i < map_size(m); ++i) { + const Type t = (Type)VKEY(m, i); + const m_bit *data = tflag(t, tflag_ref) ? + (a->data + VVAL(m, i)) : *(m_bit**)(a->data + VVAL(m, i)); + compound_release(gwion->vm->cleaner_shred, t, data); + } map_release(m); _mp_free(gwion->mp, sizeof(Closure) + a->sz, a); } -- 2.43.0