Skip to content

Commit c78b309

Browse files
shial4bghgary
andauthored
Set result pointer before clearing it. (#79)
While working with babylon we encountered issue when calling `env.drop_wrapped` calls `napi_remove_wrap` which is implemented [here](https://github.com/BabylonJS/JsRuntimeHost/blob/397c12a0f17111715177cb59364361b21905f3de/Core/Node-API/Source/js_native_api_javascriptcore.cc#L1778) for Javascriptcore It should set result to the wrapped data pointer, but that implementation will always set it to null. This change ensures that the result pointer is correctly set to the wrapped data pointer before clearing it. --------- Co-authored-by: Gary Hsu <[email protected]>
1 parent 397c12a commit c78b309

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Core/Node-API/Source/js_native_api_javascriptcore.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1784,9 +1784,10 @@ napi_status napi_remove_wrap(napi_env env, napi_value js_object, void** result)
17841784
WrapperInfo* info{};
17851785
CHECK_NAPI(WrapperInfo::Unwrap(env, js_object, &info));
17861786
RETURN_STATUS_IF_FALSE(env, info != nullptr && info->Data() != nullptr, napi_invalid_arg);
1787-
info->Data(nullptr);
17881787

17891788
*result = info->Data();
1789+
info->Data(nullptr);
1790+
17901791
return napi_ok;
17911792
}
17921793

0 commit comments

Comments
 (0)