diff --git a/src/ir/module/mod.rs b/src/ir/module/mod.rs index 315d279..eb41fe6 100644 --- a/src/ir/module/mod.rs +++ b/src/ir/module/mod.rs @@ -243,11 +243,14 @@ impl<'a> Module<'a> { } Payload::CodeSectionEntry(body) => { let locals_reader = body.get_locals_reader()?; - let num_locals = locals_reader.get_count(); let locals = locals_reader.into_iter().collect::, _>>()?; + let mut num_locals = 0; let locals: Vec<(u32, DataType)> = locals .iter() - .map(|(idx, val_type)| (*idx, DataType::from(*val_type))) + .map(|(count, val_type)| { + num_locals += count; + (*count, DataType::from(*val_type)) + }) .collect(); let instructions = body