From 006058bab73ded5adc94d4311d84c59f225b3f75 Mon Sep 17 00:00:00 2001 From: Josh Ferrell Date: Fri, 5 Jul 2024 15:35:20 -0400 Subject: Prevent parsing non-block dwarf attributes as blocks --- rust/examples/dwarf/dwarf_import/src/helpers.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'rust/examples') diff --git a/rust/examples/dwarf/dwarf_import/src/helpers.rs b/rust/examples/dwarf/dwarf_import/src/helpers.rs index 09465d82..92b08bce 100644 --- a/rust/examples/dwarf/dwarf_import/src/helpers.rs +++ b/rust/examples/dwarf/dwarf_import/src/helpers.rs @@ -264,12 +264,12 @@ pub(crate) fn get_attr_as_u64>(attr: &Attribute) -> Some(value) } else if let Some(value) = attr.sdata_value() { Some(value as u64) - } else if let Some(mut expr) = attr.exprloc_value() { - match expr.0.len() { - 1 => expr.0.read_u8().map(u64::from).ok(), - 2 => expr.0.read_u16().map(u64::from).ok(), - 4 => expr.0.read_u32().map(u64::from).ok(), - 8 => expr.0.read_u64().ok(), + } else if let AttributeValue::Block(mut data) = attr.value() { + match data.len() { + 1 => data.read_u8().map(u64::from).ok(), + 2 => data.read_u16().map(u64::from).ok(), + 4 => data.read_u32().map(u64::from).ok(), + 8 => data.read_u64().ok(), _ => None } } else { -- cgit v1.3.1