From 89c8ada068959e94bc6f7171eb1d4a08c8eddf4d Mon Sep 17 00:00:00 2001 From: Xiaobo Liu Date: Mon, 27 Jan 2025 12:14:42 +0800 Subject: [PATCH 1/2] clash_ffi: fixed ci clippy lint wrong Signed-off-by: Xiaobo Liu --- clash_ffi/src/lib.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/clash_ffi/src/lib.rs b/clash_ffi/src/lib.rs index 5308c199..196266df 100644 --- a/clash_ffi/src/lib.rs +++ b/clash_ffi/src/lib.rs @@ -11,6 +11,24 @@ pub extern "C" fn clash_start( cwd: *const c_char, multithread: c_int, ) -> *mut c_char { + if config.is_null() { + return CString::new("Error: config is null pointer") + .unwrap() + .into_raw(); + } + + if log.is_null() { + return CString::new("Error: log is null pointer") + .unwrap() + .into_raw(); + } + + if cwd.is_null() { + return CString::new("Error: cwd is null pointer") + .unwrap() + .into_raw(); + } + let config_str = unsafe { CStr::from_ptr(config) } .to_str() .unwrap_or_default() From 57fc27ba03f4dd659de8d2e3fc8ff821bdd9f510 Mon Sep 17 00:00:00 2001 From: Xiaobo Liu Date: Mon, 27 Jan 2025 13:46:04 +0800 Subject: [PATCH 2/2] tweak Signed-off-by: Xiaobo Liu --- clash_ffi/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clash_ffi/src/lib.rs b/clash_ffi/src/lib.rs index 196266df..78f6fc30 100644 --- a/clash_ffi/src/lib.rs +++ b/clash_ffi/src/lib.rs @@ -5,7 +5,7 @@ use std::{ }; #[no_mangle] -pub extern "C" fn clash_start( +pub unsafe extern "C" fn clash_start( config: *const c_char, log: *const c_char, cwd: *const c_char,