summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/wasm-s-parser.h5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/wasm-s-parser.h b/src/wasm-s-parser.h
index d10dd2bff..f3a28fd1a 100644
--- a/src/wasm-s-parser.h
+++ b/src/wasm-s-parser.h
@@ -695,8 +695,9 @@ private:
Expression* makeBlock(Element& s) {
auto ret = allocator.alloc<Block>();
size_t i = 1;
- if (s[1]->isStr()) {
- ret->name = s[1]->str();
+ if (i >= s.size()) return ret; // empty block
+ if (s[i]->isStr()) {
+ ret->name = s[i]->str();
i++;
} else {
ret->name = getPrefixedName("block");