Skip to content

Commit

Permalink
refactor!: skip first 8 bytes in module for offset
Browse files Browse the repository at this point in the history
  • Loading branch information
zhouwfang committed Jan 17, 2025
1 parent d61fe76 commit 1870912
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions crates/interpreter/src/valid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ struct Context<'m> {

impl<'m> Context<'m> {
fn check_module(&mut self, parser: &mut Parser<'m>) -> MResult<Vec<MetadataEntry>, Check> {
let module_start = parser.save().as_ptr() as usize;
check(parser.parse_bytes(8)? == b"\0asm\x01\0\0\0")?;
let module_start = parser.save().as_ptr() as usize;
if let Some(mut parser) = self.check_section(parser, SectionId::Type)? {
let n = parser.parse_vec()?;
self.types.reserve(n);
Expand Down Expand Up @@ -132,7 +132,7 @@ impl<'m> Context<'m> {
for x in imported_funcs .. self.funcs.len() {
let size = parser.parse_u32()? as usize;
let mut parser = parser.split_at(size)?;
let parser_start = parser.save().as_ptr() as usize - module_start - 8;
let parser_start = parser.save().as_ptr() as usize - module_start;
let parser_end = parser_start + size;
let t = self.functype(x as FuncIdx).unwrap();
let mut locals = t.params.to_vec();
Expand Down

0 comments on commit 1870912

Please sign in to comment.