Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/wasm/wasm-binary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2175,6 +2175,9 @@ BinaryConsts::ASTNodes WasmBinaryBuilder::readExpression(Expression*& curr) {
}

void WasmBinaryBuilder::pushBlockElements(Block* curr, size_t start, size_t end) {
assert(start <= expressionStack.size());
assert(start <= end);
assert(end <= expressionStack.size());
// the first dropped element may be consumed by code later - it was on the stack first,
// and is the only thing left on the stack. there must be just one thing on the stack
// since we are at the end of a block context. note that we may need to drop more than
Expand Down Expand Up @@ -2255,6 +2258,9 @@ Expression* WasmBinaryBuilder::getBlockOrSingleton(WasmType type) {
auto start = expressionStack.size();
processExpressions();
size_t end = expressionStack.size();
if (end < start) {
throw ParseException("block cannot pop from outside");
}
breakStack.pop_back();
auto* block = allocator.alloc<Block>();
pushBlockElements(block, start, end);
Expand Down