fix(napi): memory leak with CString

This commit is contained in:
LongYinan 2020-11-15 23:22:29 +08:00
parent 68017ce246
commit e4f005c735
No known key found for this signature in database
GPG key ID: C3666B7FC82ADAD7
2 changed files with 2 additions and 2 deletions

View file

@ -349,7 +349,7 @@ impl Env {
check_status(unsafe {
sys::napi_create_function(
self.0,
name.into_raw(),
name.as_ptr(),
len,
Some(callback),
ptr::null_mut(),

View file

@ -269,7 +269,7 @@ macro_rules! impl_object_methods {
let key = CString::new(name)?;
let mut raw_value = ptr::null_mut();
check_status(unsafe {
sys::napi_get_named_property(self.0.env, self.0.value, key.into_raw(), &mut raw_value)
sys::napi_get_named_property(self.0.env, self.0.value, key.as_ptr(), &mut raw_value)
})?;
T::from_raw(self.0.env, raw_value)
}