Skip to content

Commit

Permalink
Fix FlowGraph::low_level_il crash in Rust APi with no LLIL function o…
Browse files Browse the repository at this point in the history
…bject
  • Loading branch information
emesare committed Feb 11, 2025
1 parent 60927d1 commit f7b92a5
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions rust/src/flowgraph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(()),
}
}
Expand Down

0 comments on commit f7b92a5

Please sign in to comment.