fix(napi): CString memory leak
This commit is contained in:
parent
e337a58714
commit
c370b8374b
3 changed files with 3 additions and 5 deletions
|
@ -204,7 +204,7 @@ fn get_execute_js_code(
|
|||
Err(e) => {
|
||||
let message = format!("{}", e);
|
||||
unsafe {
|
||||
napi::sys::napi_throw_error(raw_env, ptr::null(), CString::from_vec_unchecked(message.into()).into_raw());
|
||||
napi::sys::napi_throw_error(raw_env, ptr::null(), CString::from_vec_unchecked(message.into()).as_ptr());
|
||||
}
|
||||
ptr::null_mut()
|
||||
}
|
||||
|
|
|
@ -367,9 +367,7 @@ impl Env {
|
|||
}
|
||||
|
||||
pub fn throw_error(&self, msg: &str) -> Result<()> {
|
||||
check_status(unsafe {
|
||||
sys::napi_throw_error(self.0, ptr::null(), CString::new(msg)?.into_raw())
|
||||
})
|
||||
check_status(unsafe { sys::napi_throw_error(self.0, ptr::null(), CString::new(msg)?.as_ptr()) })
|
||||
}
|
||||
|
||||
pub fn define_class(
|
||||
|
|
|
@ -188,7 +188,7 @@ macro_rules! register_module {
|
|||
raw_env,
|
||||
ptr::null(),
|
||||
CString::from_vec_unchecked(format!("Error initializing module: {}", e).into())
|
||||
.into_raw() as *const _,
|
||||
.as_ptr(),
|
||||
)
|
||||
};
|
||||
ptr::null_mut()
|
||||
|
|
Loading…
Reference in a new issue