From 33d04c64f4dd6577345dac14b564539ca37b3fee Mon Sep 17 00:00:00 2001 From: Mason Reed Date: Sun, 16 Nov 2025 20:22:37 -0500 Subject: [DWARF] Fix crash in dwarf export with detached NTR vtable data variable Fixes https://github.com/Vector35/binaryninja-api/issues/7646 Also cleaned up and added some more context to the `NamedTypeReference::target` function. --- rust/src/types.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'rust/src') diff --git a/rust/src/types.rs b/rust/src/types.rs index ffa507d8..1387ffb3 100644 --- a/rust/src/types.rs +++ b/rust/src/types.rs @@ -2080,13 +2080,13 @@ impl NamedTypeReference { match ty.type_class() { TypeClass::NamedTypeReferenceClass => { // Recurse into the NTR type until we get the target type. - let ntr = ty.get_named_type_reference().unwrap(); + let ntr = ty + .get_named_type_reference() + .expect("NTR type class should always have a valid NTR"); match visited.insert(ntr.id()) { true => ntr.target_helper(bv, visited), - false => { - log::error!("Can't get target for recursively defined type!"); - None - } + // Cyclic reference, return None. + false => None, } } // Found target type @@ -2095,6 +2095,8 @@ impl NamedTypeReference { } /// Type referenced by this [`NamedTypeReference`]. + /// + /// Will return `None` if the reference is cyclic, or the target type does not exist. pub fn target(&self, bv: &BinaryView) -> Option> { self.target_helper(bv, &mut HashSet::new()) } -- cgit v1.3.1