diff options
author | Alon Zakai <alonzakai@gmail.com> | 2017-08-02 14:47:05 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-02 14:47:05 -0700 |
commit | de15161e110f26212095c5cf4faf2e3668d2531b (patch) | |
tree | 915e18978f4b554d0479b568378a425ec5b042ee /src/wasm/wasm-binary.cpp | |
parent | 5a07a930ad51003411b2bc827ea9bf08728ecc5a (diff) | |
parent | 6d686bd1a5b3610ad49fd607ae5e49c70410af51 (diff) | |
download | binaryen-de15161e110f26212095c5cf4faf2e3668d2531b.tar.gz binaryen-de15161e110f26212095c5cf4faf2e3668d2531b.tar.bz2 binaryen-de15161e110f26212095c5cf4faf2e3668d2531b.zip |
Merge pull request #1119 from WebAssembly/fuzz-2
More fun fuzz fixes
Diffstat (limited to 'src/wasm/wasm-binary.cpp')
-rw-r--r-- | src/wasm/wasm-binary.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp index 88b967fdf..47bcc8ba5 100644 --- a/src/wasm/wasm-binary.cpp +++ b/src/wasm/wasm-binary.cpp @@ -666,6 +666,14 @@ void WasmBinaryWriter::visitSwitch(Switch *curr) { recurse(curr->value); } recurse(curr->condition); + if (!BranchUtils::isBranchTaken(curr)) { + // if the branch is not taken, then it's dangerous to emit it, as + // wasm type checking rules are stricter than ours - we tolerate + // an untaken branch to a target with a different value, but not + // wasm. so just don't emit it + o << int8_t(BinaryConsts::Unreachable); + return; + } o << int8_t(BinaryConsts::TableSwitch) << U32LEB(curr->targets.size()); for (auto target : curr->targets) { o << U32LEB(getBreakIndex(target)); @@ -1796,7 +1804,7 @@ void WasmBinaryBuilder::processExpressions() { // until an end or else marker, o Expression* WasmBinaryBuilder::popExpression() { if (expressionStack.empty()) { - throw ParseException("attempted pop from empty stack"); + throw ParseException("attempted pop from empty stack at " + std::to_string(pos)); } auto ret = expressionStack.back(); // to simulate the wasm polymorphic stack mode, leave a final |