From 31015652b81e092d7f401bf4ae74c661f012645e Mon Sep 17 00:00:00 2001 From: Hana Date: Tue, 7 Feb 2023 15:45:56 +0800 Subject: [PATCH] fix(napi): dropping Error should not call napi-sys if feature is set to noop (#1477) --- crates/napi/src/error.rs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/crates/napi/src/error.rs b/crates/napi/src/error.rs index 9fb12f0c..90f96e03 100644 --- a/crates/napi/src/error.rs +++ b/crates/napi/src/error.rs @@ -162,13 +162,16 @@ impl From for Error { impl Drop for Error { fn drop(&mut self) { - if !self.maybe_env.is_null() && !self.maybe_raw.is_null() { - let delete_reference_status = - unsafe { sys::napi_delete_reference(self.maybe_env, self.maybe_raw) }; - debug_assert!( - delete_reference_status == sys::Status::napi_ok, - "Delete Error Reference failed" - ); + #[cfg(not(feature = "noop"))] + { + if !self.maybe_env.is_null() && !self.maybe_raw.is_null() { + let delete_reference_status = + unsafe { sys::napi_delete_reference(self.maybe_env, self.maybe_raw) }; + debug_assert!( + delete_reference_status == sys::Status::napi_ok, + "Delete Error Reference failed" + ); + } } } }