Skip to content

Commit

Permalink
test: check napi_get_reference_value() during finalization
Browse files Browse the repository at this point in the history
PR-URL: #27470
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
  • Loading branch information
addaleax authored and targos committed May 1, 2019
1 parent 16af943 commit a9a85d6
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions test/js-native-api/test_reference/test_reference.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <stdlib.h>
#include <assert.h>
#include <js_native_api.h>
#include "../common.h"

Expand Down Expand Up @@ -135,6 +136,9 @@ static napi_value GetReferenceValue(napi_env env, napi_callback_info info) {
static void DeleteBeforeFinalizeFinalizer(
napi_env env, void* finalize_data, void* finalize_hint) {
napi_ref* ref = (napi_ref*)finalize_data;
napi_value value;
assert(napi_get_reference_value(env, *ref, &value) == napi_ok);
assert(value == NULL);
napi_delete_reference(env, *ref);
free(ref);
}
Expand Down

0 comments on commit a9a85d6

Please sign in to comment.