fix(napi): memory leak in create_named_property
This commit is contained in:
parent
4609fae1cb
commit
68017ce246
3 changed files with 3 additions and 3 deletions
|
@ -43,7 +43,7 @@ version = "0.3"
|
|||
|
||||
[dependencies.once_cell]
|
||||
optional = true
|
||||
version = "1.4"
|
||||
version = "1.5"
|
||||
|
||||
[dependencies.serde]
|
||||
optional = true
|
||||
|
|
|
@ -344,7 +344,7 @@ impl Env {
|
|||
|
||||
pub fn create_function(&self, name: &str, callback: Callback) -> Result<JsFunction> {
|
||||
let mut raw_result = ptr::null_mut();
|
||||
let name = CString::new(name.to_owned())?;
|
||||
let name = CString::new(name)?;
|
||||
let len = name.as_bytes().len();
|
||||
check_status(unsafe {
|
||||
sys::napi_create_function(
|
||||
|
|
|
@ -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.as_ptr(), &mut raw_value)
|
||||
sys::napi_get_named_property(self.0.env, self.0.value, key.into_raw(), &mut raw_value)
|
||||
})?;
|
||||
T::from_raw(self.0.env, raw_value)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue