Skip to content

Commit a74cf50

Browse files
Update src/js-host-api/src/lib.rs
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 96dd47a commit a74cf50

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

src/js-host-api/src/lib.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,16 +1001,21 @@ unsafe fn napi_to_json_with_buffer_extraction(
10011001
if is_typedarray {
10021002
// Probe the typed array type — only extract Uint8Array.
10031003
let mut array_type = napi::sys::TypedarrayType::int8_array;
1004+
// N-API requires valid pointers for all out-parameters.
1005+
let mut length: usize = 0;
1006+
let mut data: *mut std::ffi::c_void = std::ptr::null_mut();
1007+
let mut arraybuffer: napi_value = std::ptr::null_mut();
1008+
let mut byte_offset: usize = 0;
10041009
// SAFETY: env and val are valid, val is a typed array.
10051010
let status = unsafe {
10061011
napi::sys::napi_get_typedarray_info(
10071012
env,
10081013
val,
10091014
&mut array_type,
1010-
std::ptr::null_mut(),
1011-
std::ptr::null_mut(),
1012-
std::ptr::null_mut(),
1013-
std::ptr::null_mut(),
1015+
&mut length,
1016+
&mut data,
1017+
&mut arraybuffer,
1018+
&mut byte_offset,
10141019
)
10151020
};
10161021
if status != napi::sys::Status::napi_ok {

0 commit comments

Comments
 (0)