Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

node-api,test: fix test_reference_double_free crash #44927

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,24 @@ static napi_value New(napi_env env, napi_callback_info info) {

static void NoopDeleter(napi_env env, void* data, void* hint) {}

static void DeleteImmediately(napi_env env, napi_callback_info info) {
static napi_value DeleteImmediately(napi_env env, napi_callback_info info) {
size_t argc = 1;
napi_value js_obj;
napi_ref ref;
napi_valuetype type;
napi_value undefined;

NODE_API_CALL_RETURN_VOID(env,
napi_get_cb_info(env, info, &argc, &js_obj, NULL, NULL));
NODE_API_CALL(env, napi_get_cb_info(env, info, &argc, &js_obj, NULL, NULL));

napi_valuetype type;
NODE_API_CALL_RETURN_VOID(env, napi_typeof(env, js_obj, &type));
NODE_API_CALL(env, napi_typeof(env, js_obj, &type));
NODE_API_ASSERT(env, type == napi_object, "Expected object parameter");

NODE_API_CALL(env, napi_wrap(env, js_obj, NULL, NoopDeleter, NULL, &ref));
NODE_API_CALL(env, napi_delete_reference(env, ref));
NODE_API_CALL(env, napi_remove_wrap(env, js_obj, NULL));

NODE_API_CALL_RETURN_VOID(env,
napi_wrap(env, js_obj, NULL, NoopDeleter, NULL, &ref));
NODE_API_CALL_RETURN_VOID(env, napi_delete_reference(env, ref));
NODE_API_CALL_RETURN_VOID(env, napi_remove_wrap(env, js_obj, NULL));
NODE_API_CALL(env, napi_get_undefined(env, &undefined));
return undefined;
legendecas marked this conversation as resolved.
Show resolved Hide resolved
}

EXTERN_C_START
Expand Down