From 12bba22a456ed452efda8c951f61bdff1a516252 Mon Sep 17 00:00:00 2001 From: iximeow Date: Tue, 6 Jul 2021 21:42:09 -0700 Subject: fix incorrect `offset` and `total_offset` counts for non-`u8` Word also update yaxpeax-arch to 0.2.4 --- src/reader.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/reader.rs b/src/reader.rs index db72b79..acb0146 100644 --- a/src/reader.rs +++ b/src/reader.rs @@ -6,6 +6,7 @@ impl From for StandardDecodeError { } } +#[derive(Debug, PartialEq, Eq, Copy, Clone)] pub enum ReadError { ExhaustedInput, IOError(&'static str), @@ -167,11 +168,13 @@ macro_rules! u8reader_reader_impl { } #[inline] fn offset(&mut self) -> $addr_size { - (self.data as usize - self.mark as usize) as $addr_size + (self.data as usize - self.mark as usize) as $addr_size / + (core::mem::size_of::<$word>() as $addr_size) } #[inline] fn total_offset(&mut self) -> $addr_size { - (self.data as usize - self.start as usize) as $addr_size + (self.data as usize - self.start as usize) as $addr_size / + (core::mem::size_of::<$word>() as $addr_size) } } -- cgit v1.1