summaryrefslogtreecommitdiff
path: root/rust/examples
diff options
context:
space:
mode:
authorJosh Ferrell <josh@vector35.com>2024-09-17 17:43:07 -0400
committerJosh Ferrell <josh@vector35.com>2024-09-17 17:43:07 -0400
commit6b27ddd8a8fd3898636359681b4406c467b0f774 (patch)
tree9fe481f010e39ddd971d92f5e996313fb9de0d40 /rust/examples
parent4b947a76c44054350d472f4b83e2709d36409bc3 (diff)
Prevent crash with 0 width enum in DWARF
Diffstat (limited to 'rust/examples')
-rw-r--r--rust/examples/dwarf/dwarf_import/src/die_handlers.rs8
1 files changed, 7 insertions, 1 deletions
diff --git a/rust/examples/dwarf/dwarf_import/src/die_handlers.rs b/rust/examples/dwarf/dwarf_import/src/die_handlers.rs
index 51d52d5b..b2d61842 100644
--- a/rust/examples/dwarf/dwarf_import/src/die_handlers.rs
+++ b/rust/examples/dwarf/dwarf_import/src/die_handlers.rs
@@ -125,9 +125,15 @@ pub(crate) fn handle_enum<R: ReaderType>(
}
}
+ let width = match get_size_as_usize(entry).unwrap_or(8)
+ {
+ 0 => debug_info_builder_context.default_address_size(),
+ x => x
+ };
+
Some(Type::enumeration(
&enumeration_builder.finalize(),
- get_size_as_usize(entry).unwrap_or(8),
+ width,
false,
))
}