summaryrefslogtreecommitdiff
path: root/rust/src
diff options
context:
space:
mode:
authorGlenn Smith <glenn@vector35.com>2024-02-14 03:34:20 -0500
committerGlenn Smith <glenn@vector35.com>2024-02-14 03:34:20 -0500
commit3924284900606187048979320293633442046226 (patch)
treef09d7f4e3dfb6da1c90ea49f2a6086e197fcbc7e /rust/src
parent5315496361314009468553577251329079179996 (diff)
Rust API: Fix crash in load_with_options
Diffstat (limited to 'rust/src')
-rw-r--r--rust/src/lib.rs12
1 files changed, 7 insertions, 5 deletions
diff --git a/rust/src/lib.rs b/rust/src/lib.rs
index d5190890..c1ba83c7 100644
--- a/rust/src/lib.rs
+++ b/rust/src/lib.rs
@@ -231,16 +231,18 @@ pub fn load_with_options<S: BnStrCompatible>(
) -> Option<rc::Ref<binaryview::BinaryView>> {
let filename = filename.into_bytes_with_nul();
+ let options_or_default = if let Some(opt) = options {
+ opt
+ } else {
+ Metadata::new_of_type(MetadataType::KeyValueDataType)
+ };
+
let handle = unsafe {
binaryninjacore_sys::BNLoadFilename(
filename.as_ref().as_ptr() as *mut _,
update_analysis_and_wait,
None,
- if let Some(options) = options {
- options.as_ref().handle
- } else {
- Metadata::new_of_type(MetadataType::KeyValueDataType).handle
- },
+ options_or_default.as_ref().handle,
)
};