From f2f05739d41a4e96953dc184dd768ff308ad4983 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Fri, 12 Feb 2016 12:29:46 -0800 Subject: validate start --- src/wasm-validator.h | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'src/wasm-validator.h') diff --git a/src/wasm-validator.h b/src/wasm-validator.h index fad33a081..04493bb5b 100644 --- a/src/wasm-validator.h +++ b/src/wasm-validator.h @@ -104,6 +104,7 @@ public: shouldBeFalse(top > curr->initial); } void visitModule(Module *curr) { + // exports for (auto& exp : curr->exports) { Name name = exp->name; bool found = false; @@ -115,6 +116,14 @@ public: } shouldBeTrue(found); } + // start + if (curr->start.is()) { + auto iter = curr->functionsMap.find(curr->start); + if (shouldBeTrue(iter != curr->functionsMap.end())) { + auto func = iter->second; + shouldBeTrue(func->params.size() == 0); // must be nullary + } + } } private: @@ -135,11 +144,13 @@ private: // helpers - void shouldBeTrue(bool result) { + bool shouldBeTrue(bool result) { if (!result) valid = false; + return result; } - void shouldBeFalse(bool result) { + bool shouldBeFalse(bool result) { if (result) valid = false; + return result; } void validateAlignment(size_t align) { -- cgit v1.2.3