From bc32af2da5d9c1f6db95822263f1998803a6b267 Mon Sep 17 00:00:00 2001 From: nerodesu017 Date: Tue, 17 Dec 2024 11:35:12 +0200 Subject: [PATCH] fix: fixed wrong check related to Span --- src/core/reader/mod.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/core/reader/mod.rs b/src/core/reader/mod.rs index f263efbd..f7903905 100644 --- a/src/core/reader/mod.rs +++ b/src/core/reader/mod.rs @@ -47,7 +47,9 @@ impl<'a> WasmReader<'a> { /// [full_wasm_binary](WasmReader::full_wasm_binary), **if** the [Span]'s length is 0. For /// further information, refer to the [field documentation of `pc`](WasmReader::pc). pub fn move_start_to(&mut self, span: Span) -> Result<()> { - if span.from + span.len > self.full_wasm_binary.len() { + // Suppose we have from = 13 and len = 5 => 13,14,15,16,17 + // If our whole file has only 17 bytes, this would throw an error if we wouldn't substract one + if span.from + span.len - 1 > self.full_wasm_binary.len() { return Err(Error::Eof); }