better handle of null pointer
Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
parent
31b96a44de
commit
607f2d5d9d
@ -312,6 +312,15 @@ fn request_plugin_sign(id: String, msg_to_rustdesk: MsgToRustDesk) -> PluginRetu
|
|||||||
) {
|
) {
|
||||||
Ok(ret) => {
|
Ok(ret) => {
|
||||||
debug_assert!(!ret.msg.is_null(), "msg is null");
|
debug_assert!(!ret.msg.is_null(), "msg is null");
|
||||||
|
if ret.msg.is_null() {
|
||||||
|
// unreachable
|
||||||
|
log::error!(
|
||||||
|
"The returned message pointer of plugin status is null, plugin id: '{}', code: {}",
|
||||||
|
id,
|
||||||
|
ret.code,
|
||||||
|
);
|
||||||
|
return PluginReturn::success();
|
||||||
|
}
|
||||||
let msg = cstr_to_string(ret.msg).unwrap_or_default();
|
let msg = cstr_to_string(ret.msg).unwrap_or_default();
|
||||||
free_c_ptr(ret.msg as _);
|
free_c_ptr(ret.msg as _);
|
||||||
if ret.code == super::errno::ERR_SUCCESS {
|
if ret.code == super::errno::ERR_SUCCESS {
|
||||||
|
@ -81,7 +81,7 @@ impl PluginReturn {
|
|||||||
(self.code, "".to_owned())
|
(self.code, "".to_owned())
|
||||||
} else {
|
} else {
|
||||||
if self.msg.is_null() {
|
if self.msg.is_null() {
|
||||||
log::warn!("The message pointer is null");
|
log::warn!("The message pointer from the plugin is null, but the error code is {}", self.code);
|
||||||
return (self.code, "".to_owned())
|
return (self.code, "".to_owned())
|
||||||
}
|
}
|
||||||
let msg = cstr_to_string(self.msg).unwrap_or_default();
|
let msg = cstr_to_string(self.msg).unwrap_or_default();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user