fix(napi): memory issue while creating external buffer on electron
This commit is contained in:
parent
aff95d0271
commit
b9ba7c9d68
2 changed files with 3 additions and 3 deletions
|
@ -405,7 +405,7 @@ macro_rules! impl_typed_array {
|
||||||
&mut arraybuffer_value,
|
&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
|
status
|
||||||
} else {
|
} else {
|
||||||
status
|
status
|
||||||
|
|
|
@ -461,7 +461,7 @@ impl Env {
|
||||||
let mut underlying_data = ptr::null_mut();
|
let mut underlying_data = ptr::null_mut();
|
||||||
let status =
|
let status =
|
||||||
sys::napi_create_arraybuffer(self.0, length, &mut underlying_data, &mut raw_value);
|
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
|
status
|
||||||
} else {
|
} else {
|
||||||
status
|
status
|
||||||
|
@ -476,7 +476,7 @@ impl Env {
|
||||||
value: raw_value,
|
value: raw_value,
|
||||||
value_type: ValueType::Object,
|
value_type: ValueType::Object,
|
||||||
}),
|
}),
|
||||||
data_ptr as *mut c_void,
|
data_ptr.cast(),
|
||||||
length,
|
length,
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue