From f7b92a5167456adb9580d40ff0b08bf2896cb33e Mon Sep 17 00:00:00 2001 From: Mason Reed Date: Tue, 11 Feb 2025 14:30:29 -0500 Subject: Fix FlowGraph::low_level_il crash in Rust APi with no LLIL function object --- rust/src/flowgraph.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'rust/src/flowgraph.rs') 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>, ()> { 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(()), } } -- cgit v1.3.1