From 40506fd6b2151b5b867730c8a214be229af0a77e Mon Sep 17 00:00:00 2001 From: Sage Vaillancourt Date: Mon, 11 Apr 2022 16:49:44 -0400 Subject: [PATCH] Fix more async leakage. --- src/env.c | 6 +++++- src/threads.c | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/env.c b/src/env.c index b541e44..ec796c9 100644 --- a/src/env.c +++ b/src/env.c @@ -445,7 +445,11 @@ int runTests(int detailed, int specificTest) struct helpText h = helpTexts[hi]; if (h.tests) { if (detailed && h.testCount > 0) { - printf(" `%s` ", h.symbol); + if (isSpecific) { + printf("`%s` ", h.symbol); + } else { + printf(" `%s` ", h.symbol); + } } for (int ti = 0; ti < h.testCount; ti += 2) { const char* test = h.tests[ti]; diff --git a/src/threads.c b/src/threads.c index 4a980bd..047d006 100644 --- a/src/threads.c +++ b/src/threads.c @@ -61,6 +61,7 @@ void* doAsync(void* args) promise->done = 1; cleanPromise(promise); + deleteEnv(promise->env); cleanObject(&cloned); return NULL; } @@ -75,6 +76,7 @@ Object async(Object* params, int length, struct Environment* env) .env = env, .object = cloneObject(params[0]), }; + env->refs += 1; pthread_create(&promise.promise->thread, NULL, doAsync, promise.promise); return promise;