diff --git a/Userland/Libraries/LibWasm/AbstractMachine/Validator.cpp b/Userland/Libraries/LibWasm/AbstractMachine/Validator.cpp index 50bb5703dd9..2606e394cca 100644 --- a/Userland/Libraries/LibWasm/AbstractMachine/Validator.cpp +++ b/Userland/Libraries/LibWasm/AbstractMachine/Validator.cpp @@ -1950,6 +1950,8 @@ VALIDATE_INSTRUCTION(memory_copy) VALIDATE_INSTRUCTION(memory_init) { + if (!m_context.data_count.has_value()) + return Errors::invalid("memory.init, requires data count section"sv); auto& args = instruction.arguments().get(); @@ -1963,6 +1965,9 @@ VALIDATE_INSTRUCTION(memory_init) VALIDATE_INSTRUCTION(data_drop) { + if (!m_context.data_count.has_value()) + return Errors::invalid("data.drop, requires data count section"sv); + auto index = instruction.arguments().get(); TRY(validate(index));