Skip to content

Commit

Permalink
Fix crash with unnamed function self reference in DWARF import
Browse files Browse the repository at this point in the history
  • Loading branch information
emesare committed Feb 4, 2025
1 parent d6856d7 commit f097e0a
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions plugins/dwarf/dwarf_import/src/die_handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,11 +316,9 @@ pub(crate) fn handle_function<R: ReaderType>(
};

Check warning on line 316 in plugins/dwarf/dwarf_import/src/die_handlers.rs

View workflow job for this annotation

GitHub Actions / cargo fmt

Diff in /home/runner/work/binaryninja-api/binaryninja-api/plugins/dwarf/dwarf_import/src/die_handlers.rs

// Alias function type in the case that it contains itself
if let Some(name) = debug_info_builder_context.get_name(dwarf, unit, entry) {
let ntr =
Type::named_type_from_type(&name, &Type::function(return_type.as_ref(), vec![], false));
debug_info_builder.add_type(get_uid(dwarf, unit, entry), name, ntr, false);
}
let name = debug_info_builder_context.get_name(dwarf, unit, entry).unwrap_or("_unnamed_func".to_string());
let ntr = Type::named_type_from_type(&name, &Type::function(return_type.as_ref(), vec![], false));
debug_info_builder.add_type(get_uid(dwarf, unit, entry), name, ntr, false);

let mut parameters: Vec<FunctionParameter> = vec![];
let mut variable_arguments = false;
Expand Down Expand Up @@ -350,12 +348,8 @@ pub(crate) fn handle_function<R: ReaderType>(
}
}

if debug_info_builder_context
.get_name(dwarf, unit, entry)
.is_some()
{
debug_info_builder.remove_type(get_uid(dwarf, unit, entry));
}
// Remove the aliased type from the builder.
debug_info_builder.remove_type(get_uid(dwarf, unit, entry));

Some(Type::function(
return_type.as_ref(),
Expand Down

0 comments on commit f097e0a

Please sign in to comment.