From 8c2125e9db04c214cd23018cecc237365de2ace5 Mon Sep 17 00:00:00 2001 From: evilg Date: Thu, 3 Oct 2024 11:59:27 -0400 Subject: [PATCH] Fix buggy init local_count (#213) * Fix buggy init local_count * remove commented-out line --- src/ir/module/mod.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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