Skip to content

Commit

Permalink
Solved memory leak in node loader.
Browse files Browse the repository at this point in the history
  • Loading branch information
viferga committed Jan 30, 2024
1 parent a8c3325 commit bf91ec6
Showing 1 changed file with 2 additions and 15 deletions.
17 changes: 2 additions & 15 deletions source/loaders/node_loader/source/node_loader_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2219,7 +2219,6 @@ void node_loader_impl_func_await_safe(napi_env env, loader_impl_async_func_await

if (trampoline != NULL)
{
napi_ref trampoline_ref;
size_t args_size;
value *args;
loader_impl_node_function node_func;
Expand Down Expand Up @@ -2278,7 +2277,7 @@ void node_loader_impl_func_await_safe(napi_env env, loader_impl_async_func_await

node_loader_impl_exception(env, status);

status = napi_wrap(env, argv[2], static_cast<void *>(trampoline), &node_loader_impl_async_func_await_finalize, NULL, &trampoline_ref);
status = napi_wrap(env, argv[2], static_cast<void *>(trampoline), &node_loader_impl_async_func_await_finalize, NULL, NULL);

node_loader_impl_exception(env, status);

Expand All @@ -2293,11 +2292,6 @@ void node_loader_impl_func_await_safe(napi_env env, loader_impl_async_func_await

node_loader_impl_exception(env, status);

/* Delete references references to wrapped objects */
status = napi_delete_reference(env, trampoline_ref);

node_loader_impl_exception(env, status);

/* Proccess the await return */
func_await_safe->ret = node_loader_impl_napi_to_value(func_await_safe->node_impl, env, func_await_safe->recv, await_return);

Expand Down Expand Up @@ -2457,8 +2451,6 @@ void node_loader_impl_future_await_safe(napi_env env, loader_impl_async_future_a

if (trampoline != NULL)
{
napi_ref trampoline_ref;

/* Get function reference */
status = napi_get_reference_value(env, future_await_safe->node_future->promise_ref, &argv[0]);

Expand All @@ -2477,7 +2469,7 @@ void node_loader_impl_future_await_safe(napi_env env, loader_impl_async_future_a

node_loader_impl_exception(env, status);

status = napi_wrap(env, argv[1], static_cast<void *>(trampoline), &node_loader_impl_async_func_await_finalize, NULL, &trampoline_ref);
status = napi_wrap(env, argv[1], static_cast<void *>(trampoline), &node_loader_impl_async_func_await_finalize, NULL, NULL);

node_loader_impl_exception(env, status);

Expand All @@ -2492,11 +2484,6 @@ void node_loader_impl_future_await_safe(napi_env env, loader_impl_async_future_a

node_loader_impl_exception(env, status);

/* Delete references references to wrapped objects */
status = napi_delete_reference(env, trampoline_ref);

node_loader_impl_exception(env, status);

/* Proccess the await return */
future_await_safe->ret = node_loader_impl_napi_to_value(future_await_safe->node_impl, env, future_await_safe->recv, await_return);
}
Expand Down

0 comments on commit bf91ec6

Please sign in to comment.