summaryrefslogtreecommitdiff
path: root/rust
diff options
context:
space:
mode:
authorMason Reed <mason@vector35.com>2025-02-11 14:30:29 -0500
committerMason Reed <mason@vector35.com>2025-02-11 14:30:29 -0500
commitf7b92a5167456adb9580d40ff0b08bf2896cb33e (patch)
tree1d1ec2acabeb249dc389438bca7df33187569dee /rust
parent60927d114f7fffea016d58fed5d1a6ccde1ec130 (diff)
Fix FlowGraph::low_level_il crash in Rust APi with no LLIL function object
Diffstat (limited to 'rust')
-rw-r--r--rust/src/flowgraph.rs12
1 files changed, 7 insertions, 5 deletions
diff --git a/rust/src/flowgraph.rs b/rust/src/flowgraph.rs
index a3212676..69e97bb9 100644
--- a/rust/src/flowgraph.rs
+++ b/rust/src/flowgraph.rs
@@ -58,12 +58,14 @@ impl FlowGraph {
pub fn low_level_il(&self) -> Result<Ref<RegularLowLevelILFunction<CoreArchitecture>>, ()> {
unsafe {
let llil_ptr = BNGetFlowGraphLowLevelILFunction(self.handle);
- let func_ptr = BNGetLowLevelILOwnerFunction(llil_ptr);
- let arch_ptr = BNGetFunctionArchitecture(func_ptr);
- let arch = CoreArchitecture::from_raw(arch_ptr);
- BNFreeFunction(func_ptr);
match llil_ptr.is_null() {
- false => Ok(RegularLowLevelILFunction::ref_from_raw(arch, llil_ptr)),
+ false => {
+ let func_ptr = BNGetLowLevelILOwnerFunction(llil_ptr);
+ let arch_ptr = BNGetFunctionArchitecture(func_ptr);
+ let arch = CoreArchitecture::from_raw(arch_ptr);
+ BNFreeFunction(func_ptr);
+ Ok(RegularLowLevelILFunction::ref_from_raw(arch, llil_ptr))
+ },
true => Err(()),
}
}