diff --git a/src/read/loclists.rs b/src/read/loclists.rs index 380b2c9e..66fd0eb9 100644 --- a/src/read/loclists.rs +++ b/src/read/loclists.rs @@ -650,15 +650,10 @@ impl LocListIter { } }; - if range.begin == tombstone { + if range.begin == tombstone || range.begin > range.end { return Ok(None); } - if range.begin > range.end { - self.raw.input.empty(); - return Err(Error::InvalidLocationAddressRange); - } - Ok(Some(LocationListEntry { range, data })) } } @@ -1522,7 +1517,7 @@ mod tests { debug_addr_base, ) .unwrap(); - assert_eq!(locations.next(), Err(Error::InvalidLocationAddressRange)); + assert_eq!(locations.next(), Ok(None)); // An invalid location range after wrapping. let mut locations = loclists @@ -1534,7 +1529,7 @@ mod tests { debug_addr_base, ) .unwrap(); - assert_eq!(locations.next(), Err(Error::InvalidLocationAddressRange)); + assert_eq!(locations.next(), Ok(None)); // An invalid offset. match loclists.locations( diff --git a/src/read/mod.rs b/src/read/mod.rs index 9b974ecd..6371ae7c 100644 --- a/src/read/mod.rs +++ b/src/read/mod.rs @@ -386,8 +386,6 @@ pub enum Error { UnknownCallFrameInstruction(constants::DwCfa), /// The end of an address range was before the beginning. InvalidAddressRange, - /// The end offset of a loc list entry was before the beginning. - InvalidLocationAddressRange, /// Encountered a call frame instruction in a context in which it is not /// valid. CfiInstructionInInvalidContext, @@ -547,9 +545,6 @@ impl Error { Error::InvalidAddressRange => { "The end of an address range must not be before the beginning." } - Error::InvalidLocationAddressRange => { - "The end offset of a location list entry must not be before the beginning." - } Error::CfiInstructionInInvalidContext => { "Encountered a call frame instruction in a context in which it is not valid." } diff --git a/src/read/rnglists.rs b/src/read/rnglists.rs index fcd9be13..f3f713d7 100644 --- a/src/read/rnglists.rs +++ b/src/read/rnglists.rs @@ -569,15 +569,10 @@ impl RngListIter { } }; - if range.begin == tombstone { + if range.begin == tombstone || range.begin > range.end { return Ok(None); } - if range.begin > range.end { - self.raw.input.empty(); - return Err(Error::InvalidAddressRange); - } - Ok(Some(range)) } } @@ -1402,7 +1397,7 @@ mod tests { debug_addr_base, ) .unwrap(); - assert_eq!(ranges.next(), Err(Error::InvalidAddressRange)); + assert_eq!(ranges.next(), Ok(None)); // An invalid range after wrapping. let mut ranges = rnglists @@ -1414,7 +1409,7 @@ mod tests { debug_addr_base, ) .unwrap(); - assert_eq!(ranges.next(), Err(Error::InvalidAddressRange)); + assert_eq!(ranges.next(), Ok(None)); // An invalid offset. match rnglists.ranges(