diff --git a/src/task.c b/src/task.c index faf72e22..71351ecb 100644 --- a/src/task.c +++ b/src/task.c @@ -1819,6 +1819,12 @@ void tf_task_destroy(tf_task_t* task) { JS_FreeValue(task->_context, task->_exports[i]->_function); } + while (task->_import_count) + { + while (!_import_record_release(&task->_imports[task->_import_count - 1])) + { + } + } tf_free(task->_imports); tf_free(task->_exports); task->_imports = NULL; @@ -1831,10 +1837,7 @@ void tf_task_destroy(tf_task_t* task) while (task->timeouts) { timeout_t* timeout = task->timeouts; - if (task->_context) - { - JS_FreeValue(task->_context, timeout->_callback); - } + JS_FreeValue(task->_context, timeout->_callback); timeout->_callback = JS_UNDEFINED; _timeout_unlink(task, timeout); uv_close((uv_handle_t*)&timeout->_timer, _timeout_closed); @@ -1859,14 +1862,6 @@ void tf_task_destroy(tf_task_t* task) tf_free(task->_promises); task->_promises = NULL; - tf_free(task->_imports); - task->_imports = NULL; - task->_import_count = 0; - - tf_free(task->_exports); - task->_exports = NULL; - task->_export_count = 0; - if (task->_db) { sqlite3_close(task->_db);