mirror of
https://github.com/janet-lang/janet
synced 2025-01-05 05:10:26 +00:00
Fix memory leak with weak table frees.
The backing buffer for weak arrays and tables was not freed upon being garbage collected. This shows up in traces and valgrind. Verified by running `make valtest` with changes.
This commit is contained in:
parent
f553c5da47
commit
75bdea5155
@ -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;
|
||||
|
@ -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: {
|
||||
|
Loading…
Reference in New Issue
Block a user