From 31b96a44de7465ff47c5cc4e5e20e9fe33771104 Mon Sep 17 00:00:00 2001 From: fufesou Date: Tue, 16 May 2023 16:11:45 +0800 Subject: [PATCH] remove assert Signed-off-by: fufesou --- src/plugin/callback_msg.rs | 2 +- src/plugin/mod.rs | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/plugin/callback_msg.rs b/src/plugin/callback_msg.rs index 9a82adfec..826aa159f 100644 --- a/src/plugin/callback_msg.rs +++ b/src/plugin/callback_msg.rs @@ -311,7 +311,7 @@ fn request_plugin_sign(id: String, msg_to_rustdesk: MsgToRustDesk) -> PluginRetu &[], ) { Ok(ret) => { - assert!(!ret.msg.is_null()); + debug_assert!(!ret.msg.is_null(), "msg is null"); let msg = cstr_to_string(ret.msg).unwrap_or_default(); free_c_ptr(ret.msg as _); if ret.code == super::errno::ERR_SUCCESS { diff --git a/src/plugin/mod.rs b/src/plugin/mod.rs index f19f67dd1..d0b326dc3 100644 --- a/src/plugin/mod.rs +++ b/src/plugin/mod.rs @@ -80,7 +80,10 @@ impl PluginReturn { if self.is_success() { (self.code, "".to_owned()) } else { - debug_assert!(!self.msg.is_null(), "msg is null"); + if self.msg.is_null() { + log::warn!("The message pointer is null"); + return (self.code, "".to_owned()) + } let msg = cstr_to_string(self.msg).unwrap_or_default(); free_c_ptr(self.msg as _); self.msg = null(); @@ -146,7 +149,6 @@ fn get_uninstall_file_path() -> ResultType { #[inline] fn cstr_to_string(cstr: *const c_char) -> ResultType { - assert!(!cstr.is_null(), "cstr must be a valid pointer"); if cstr.is_null() { bail!("failed to convert string, the pointer is null"); }