diff options
author | Divy Srivastava <dj.srivastava23@gmail.com> | 2023-01-22 01:34:18 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-22 15:04:18 +0530 |
commit | c3e3694b9df3154f17796c23e027dc9d2ffc4c91 (patch) | |
tree | 7fdf48df9cf6a2731cc59cb72d07b0fc07fd2b85 /ext/napi/function.rs | |
parent | 59289255411b902588619fd7d2f6e3e48af11d82 (diff) |
fix(napi): correctly handle name in napi_create_function (#17489)
Fixes https://github.com/denoland/deno/issues/17472
Diffstat (limited to 'ext/napi/function.rs')
-rw-r--r-- | ext/napi/function.rs | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/ext/napi/function.rs b/ext/napi/function.rs index aec402149..f921c4838 100644 --- a/ext/napi/function.rs +++ b/ext/napi/function.rs @@ -51,7 +51,7 @@ extern "C" fn call_fn(info: *const v8::FunctionCallbackInfo) { #[allow(clippy::not_unsafe_ptr_arg_deref)] pub fn create_function<'a>( env_ptr: *mut Env, - name: Option<&str>, + name: Option<v8::Local<v8::String>>, cb: napi_callback, cb_info: napi_callback_info, ) -> v8::Local<'a, v8::Function> { @@ -67,8 +67,7 @@ pub fn create_function<'a>( .build(scope) .unwrap(); - if let Some(name) = name { - let v8str = v8::String::new(scope, name).unwrap(); + if let Some(v8str) = name { function.set_name(v8str); } |