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) => {
|
Err(e) => {
|
||||||
let message = format!("{}", e);
|
let message = format!("{}", e);
|
||||||
unsafe {
|
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()
|
ptr::null_mut()
|
||||||
}
|
}
|
||||||
|
|
|
@ -367,9 +367,7 @@ impl Env {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn throw_error(&self, msg: &str) -> Result<()> {
|
pub fn throw_error(&self, msg: &str) -> Result<()> {
|
||||||
check_status(unsafe {
|
check_status(unsafe { sys::napi_throw_error(self.0, ptr::null(), CString::new(msg)?.as_ptr()) })
|
||||||
sys::napi_throw_error(self.0, ptr::null(), CString::new(msg)?.into_raw())
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn define_class(
|
pub fn define_class(
|
||||||
|
|
|
@ -188,7 +188,7 @@ macro_rules! register_module {
|
||||||
raw_env,
|
raw_env,
|
||||||
ptr::null(),
|
ptr::null(),
|
||||||
CString::from_vec_unchecked(format!("Error initializing module: {}", e).into())
|
CString::from_vec_unchecked(format!("Error initializing module: {}", e).into())
|
||||||
.into_raw() as *const _,
|
.as_ptr(),
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
ptr::null_mut()
|
ptr::null_mut()
|
||||||
|
|
Loading…
Reference in a new issue