Skip to content

Commit e61ea11

Browse files
simongdaviesCopilot
andcommitted
Update src/js-host-api/src/lib.rs
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Simon Davies <simongdavies@users.noreply.github.com>
1 parent f72579a commit e61ea11

2 files changed

Lines changed: 18 additions & 4 deletions

File tree

Cargo.lock

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,16 +1015,21 @@ unsafe fn napi_to_json_with_buffer_extraction(
10151015
if is_typedarray {
10161016
// Probe the typed array type — only extract Uint8Array.
10171017
let mut array_type = napi::sys::TypedarrayType::int8_array;
1018+
// N-API requires valid pointers for all out-parameters.
1019+
let mut length: usize = 0;
1020+
let mut data: *mut std::ffi::c_void = std::ptr::null_mut();
1021+
let mut arraybuffer: napi_value = std::ptr::null_mut();
1022+
let mut byte_offset: usize = 0;
10181023
// SAFETY: env and val are valid, val is a typed array.
10191024
let status = unsafe {
10201025
napi::sys::napi_get_typedarray_info(
10211026
env,
10221027
val,
10231028
&mut array_type,
1024-
std::ptr::null_mut(),
1025-
std::ptr::null_mut(),
1026-
std::ptr::null_mut(),
1027-
std::ptr::null_mut(),
1029+
&mut length,
1030+
&mut data,
1031+
&mut arraybuffer,
1032+
&mut byte_offset,
10281033
)
10291034
};
10301035
if status != napi::sys::Status::napi_ok {

0 commit comments

Comments
 (0)