Skip to content

Commit f7b92a5

Browse files
committed
Fix FlowGraph::low_level_il crash in Rust APi with no LLIL function object
1 parent 60927d1 commit f7b92a5

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

rust/src/flowgraph.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,14 @@ impl FlowGraph {
5858
pub fn low_level_il(&self) -> Result<Ref<RegularLowLevelILFunction<CoreArchitecture>>, ()> {
5959
unsafe {
6060
let llil_ptr = BNGetFlowGraphLowLevelILFunction(self.handle);
61-
let func_ptr = BNGetLowLevelILOwnerFunction(llil_ptr);
62-
let arch_ptr = BNGetFunctionArchitecture(func_ptr);
63-
let arch = CoreArchitecture::from_raw(arch_ptr);
64-
BNFreeFunction(func_ptr);
6561
match llil_ptr.is_null() {
66-
false => Ok(RegularLowLevelILFunction::ref_from_raw(arch, llil_ptr)),
62+
false => {
63+
let func_ptr = BNGetLowLevelILOwnerFunction(llil_ptr);
64+
let arch_ptr = BNGetFunctionArchitecture(func_ptr);
65+
let arch = CoreArchitecture::from_raw(arch_ptr);
66+
BNFreeFunction(func_ptr);
67+
Ok(RegularLowLevelILFunction::ref_from_raw(arch, llil_ptr))
68+
},
6769
true => Err(()),
6870
}
6971
}

0 commit comments

Comments
 (0)