From 67691e36bc03960d4f5df5f2471015656186b1a3 Mon Sep 17 00:00:00 2001 From: Sage Vaillancourt Date: Wed, 6 Apr 2022 00:03:34 -0400 Subject: [PATCH] Fix Promise env longevity. --- src/threads.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/threads.c b/src/threads.c index e90d3ff..815e623 100644 --- a/src/threads.c +++ b/src/threads.c @@ -29,6 +29,7 @@ void cleanPromise(struct Promise* promise) { promise->refs -= 1; if (promise->refs == 0) { + deleteEnv(promise->env); free(promise); } } @@ -68,6 +69,7 @@ Object async(Object* params, int length, struct Environment* env) .env = env, .object = params[0], // TODO: Clone? }; + env->refs += 1; pthread_create(&promise.promise->thread, NULL, doAsync, promise.promise); return promise;