diff options
| author | Brandon Miller <brandon@vector35.com> | 2025-09-26 08:33:48 -0400 |
|---|---|---|
| committer | Brandon Miller <brandon@vector35.com> | 2025-09-29 07:07:41 -0400 |
| commit | df599006c0a805dda992910722ac69a9adf794fc (patch) | |
| tree | 4d6b9643febf2d9d5f259d2d827846a13addec7a /rust | |
| parent | 9a9d7d98c2b49c734771397a8d37aca0279dfa21 (diff) | |
Fix Rust LowLevelILFunction owner function method
LowLevelILFunction objects can be constructed without a owner
function. BNGetLowLevelILOwnerFunction can return NULL and must be
checked before creating a Function object.
Diffstat (limited to 'rust')
| -rw-r--r-- | rust/src/low_level_il/function.rs | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/rust/src/low_level_il/function.rs b/rust/src/low_level_il/function.rs index 65c3536a..ca6508c9 100644 --- a/rust/src/low_level_il/function.rs +++ b/rust/src/low_level_il/function.rs @@ -88,8 +88,9 @@ where } pub(crate) fn arch(&self) -> CoreArchitecture { + // TODO: self.function() can return None under rare circumstances match self.arch { - None => self.function().arch(), + None => self.function().unwrap().arch(), Some(arch) => arch, } } @@ -167,10 +168,13 @@ where } } - pub fn function(&self) -> Ref<Function> { + pub fn function(&self) -> Option<Ref<Function>> { unsafe { let func = BNGetLowLevelILOwnerFunction(self.handle); - Function::ref_from_raw(func) + if func.is_null() { + return None; + } + Some(Function::ref_from_raw(func)) } } |
