summaryrefslogtreecommitdiff
path: root/test_napi/src
diff options
context:
space:
mode:
authorDivy Srivastava <dj.srivastava23@gmail.com>2023-01-23 05:29:46 -0800
committerGitHub <noreply@github.com>2023-01-23 18:59:46 +0530
commitc3e0b12c72673badece8ef5d789a942637d893ba (patch)
treee46e85e98b1ec9b7649e936b3794f348e408ca74 /test_napi/src
parentb96bbc32c8a0828f997f6148111a31ec27ec08b1 (diff)
fix(napi): handle return value from initializer (#17502)
Fixes https://github.com/denoland/deno/issues/17349
Diffstat (limited to 'test_napi/src')
-rw-r--r--test_napi/src/lib.rs9
1 files changed, 8 insertions, 1 deletions
diff --git a/test_napi/src/lib.rs b/test_napi/src/lib.rs
index c02e53da4..78a8248dc 100644
--- a/test_napi/src/lib.rs
+++ b/test_napi/src/lib.rs
@@ -123,13 +123,20 @@ pub fn init_cleanup_hook(env: napi_env, exports: napi_value) {
#[no_mangle]
unsafe extern "C" fn napi_register_module_v1(
env: napi_env,
- exports: napi_value,
+ _: napi_value,
) -> napi_value {
#[cfg(windows)]
{
napi_sys::setup();
}
+ // We create a fresh exports object and leave the passed
+ // exports object empty.
+ //
+ // https://github.com/denoland/deno/issues/17349
+ let mut exports = std::ptr::null_mut();
+ assert_napi_ok!(napi_create_object(env, &mut exports));
+
strings::init(env, exports);
numbers::init(env, exports);
typedarray::init(env, exports);