diff --git a/src/core/ev.c b/src/core/ev.c index 03a4b623..9c457539 100644 --- a/src/core/ev.c +++ b/src/core/ev.c @@ -255,6 +255,12 @@ static void add_timeout(JanetTimeout to) { void janet_async_end(JanetFiber *fiber) { if (fiber->ev_callback) { + if (fiber->ev_stream->read_fiber == fiber) { + fiber->ev_stream->read_fiber = NULL; + } + if (fiber->ev_stream->write_fiber == fiber) { + fiber->ev_stream->write_fiber = NULL; + } fiber->ev_callback(fiber, JANET_ASYNC_EVENT_DEINIT); janet_gcunroot(janet_wrap_abstract(fiber->ev_stream)); fiber->ev_callback = NULL; diff --git a/src/core/gc.c b/src/core/gc.c index ba05a5a6..e9c8aef8 100644 --- a/src/core/gc.c +++ b/src/core/gc.c @@ -321,9 +321,13 @@ static void janet_deinit_block(JanetGCObject *mem) { janet_symbol_deinit(((JanetStringHead *) mem)->data); break; case JANET_MEMORY_ARRAY: + case JANET_MEMORY_ARRAY_WEAK: janet_free(((JanetArray *) mem)->data); break; case JANET_MEMORY_TABLE: + case JANET_MEMORY_TABLE_WEAKK: + case JANET_MEMORY_TABLE_WEAKV: + case JANET_MEMORY_TABLE_WEAKKV: janet_free(((JanetTable *) mem)->data); break; case JANET_MEMORY_FIBER: {