diff --git a/Userland/Libraries/LibWasm/AbstractMachine/Validator.cpp b/Userland/Libraries/LibWasm/AbstractMachine/Validator.cpp index fcbb76525f1..eb994d49e3f 100644 --- a/Userland/Libraries/LibWasm/AbstractMachine/Validator.cpp +++ b/Userland/Libraries/LibWasm/AbstractMachine/Validator.cpp @@ -38,7 +38,8 @@ ErrorOr Validator::validate(Module& module) m_context = {}; module.for_each_section_of_type([this](TypeSection const& section) { - m_context.types = section.types(); + for (auto& type : section.types()) + m_context.types.append(type); }); module.for_each_section_of_type([&](ImportSection const& section) { @@ -90,23 +91,23 @@ ErrorOr Validator::validate(Module& module) module.for_each_section_of_type([this](TableSection const& section) { m_context.tables.ensure_capacity(m_context.tables.size() + section.tables().size()); for (auto& table : section.tables()) - m_context.tables.unchecked_append(table.type()); + m_context.tables.append(table.type()); }); module.for_each_section_of_type([this](MemorySection const& section) { m_context.memories.ensure_capacity(m_context.memories.size() + section.memories().size()); for (auto& memory : section.memories()) - m_context.memories.unchecked_append(memory.type()); + m_context.memories.append(memory.type()); }); module.for_each_section_of_type([this](GlobalSection const& section) { m_context.globals.ensure_capacity(m_context.globals.size() + section.entries().size()); for (auto& global : section.entries()) - m_context.globals.unchecked_append(global.type()); + m_context.globals.append(global.type()); }); module.for_each_section_of_type([this](ElementSection const& section) { m_context.elements.ensure_capacity(section.segments().size()); for (auto& segment : section.segments()) - m_context.elements.unchecked_append(segment.type); + m_context.elements.append(segment.type); }); module.for_each_section_of_type([this](DataSection const& section) { m_context.datas.resize(section.data().size()); diff --git a/Userland/Libraries/LibWasm/AbstractMachine/Validator.h b/Userland/Libraries/LibWasm/AbstractMachine/Validator.h index bcf7377487e..7e69b0ae337 100644 --- a/Userland/Libraries/LibWasm/AbstractMachine/Validator.h +++ b/Userland/Libraries/LibWasm/AbstractMachine/Validator.h @@ -6,6 +6,7 @@ #pragma once +#include #include #include #include @@ -17,15 +18,15 @@ namespace Wasm { struct Context { - Vector types; - Vector functions; - Vector tables; - Vector memories; - Vector globals; - Vector elements; - Vector datas; - Vector locals; - Vector labels; + COWVector types; + COWVector functions; + COWVector tables; + COWVector memories; + COWVector globals; + COWVector elements; + COWVector datas; + COWVector locals; + COWVector labels; Optional return_; AK::HashTable references; size_t imported_function_count { 0 }; @@ -345,7 +346,7 @@ private: Vector m_entered_scopes; Vector m_block_details; Vector m_entered_blocks; - Vector m_globals_without_internal_globals; + COWVector m_globals_without_internal_globals; }; }