diff --git a/crates/napi/src/bindgen_runtime/js_values/arraybuffer.rs b/crates/napi/src/bindgen_runtime/js_values/arraybuffer.rs index d3bdde48..ba57e3ca 100644 --- a/crates/napi/src/bindgen_runtime/js_values/arraybuffer.rs +++ b/crates/napi/src/bindgen_runtime/js_values/arraybuffer.rs @@ -405,7 +405,7 @@ macro_rules! impl_typed_array { &mut arraybuffer_value, ) }; - unsafe { std::ptr::copy(hint.data.cast(), underlying_data, length) }; + unsafe { std::ptr::copy_nonoverlapping(hint.data.cast(), underlying_data, length) }; status } else { status diff --git a/crates/napi/src/env.rs b/crates/napi/src/env.rs index 92bbdc9b..352d2235 100644 --- a/crates/napi/src/env.rs +++ b/crates/napi/src/env.rs @@ -461,7 +461,7 @@ impl Env { let mut underlying_data = ptr::null_mut(); let status = sys::napi_create_arraybuffer(self.0, length, &mut underlying_data, &mut raw_value); - ptr::swap(underlying_data.cast(), data_ptr); + ptr::copy_nonoverlapping(underlying_data.cast(), data_ptr, length); status } else { status @@ -476,7 +476,7 @@ impl Env { value: raw_value, value_type: ValueType::Object, }), - data_ptr as *mut c_void, + data_ptr.cast(), length, )) }