From 052a8d2adb0c7899ae875c03da4edf80b2fa1a81 Mon Sep 17 00:00:00 2001 From: KyleMiles Date: Wed, 20 Sep 2023 14:40:22 -0400 Subject: Rust API : FFI Fix, was leaking some non-null-terminated strings to the core..fix passing a nullptr to `load` --- rust/src/headless.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'rust/src/headless.rs') diff --git a/rust/src/headless.rs b/rust/src/headless.rs index 0ce24cb3..c5e14eb0 100644 --- a/rust/src/headless.rs +++ b/rust/src/headless.rs @@ -12,8 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +use crate::string::BnStrCompatible; + use std::env; -use std::ffi::CString; use std::path::PathBuf; #[cfg(not(target_os = "windows"))] @@ -72,9 +73,9 @@ use binaryninjacore_sys::{BNInitPlugins, BNInitRepoPlugins, BNSetBundledPluginDi pub fn init() { unsafe { let path = binja_path().join("plugins").into_os_string(); - let path = CString::new(path.into_string().unwrap()).unwrap(); + let path = path.into_string().unwrap(); - BNSetBundledPluginDirectory(path.as_ptr()); + BNSetBundledPluginDirectory(path.as_str().into_bytes_with_nul().as_ptr() as *mut _); BNInitPlugins(true); BNInitRepoPlugins(); } -- cgit v1.3.1