diff options
author | Alon Zakai <alonzakai@gmail.com> | 2017-05-02 13:45:37 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-02 13:45:37 -0700 |
commit | 7addcae1ea9a09b8c82e0ad660323a42d6535baa (patch) | |
tree | bfb1f13195ece4b657db89ba86a0f6adae55bdff /src/wasm/wasm-s-parser.cpp | |
parent | 6ae56e73d0eb3a5769af3920a2e75e0a910777bb (diff) | |
download | binaryen-7addcae1ea9a09b8c82e0ad660323a42d6535baa.tar.gz binaryen-7addcae1ea9a09b8c82e0ad660323a42d6535baa.tar.bz2 binaryen-7addcae1ea9a09b8c82e0ad660323a42d6535baa.zip |
Parsing fixes (#990)
* properly catch a bunch of possible parse errors, found by afl-fuzz
* clean up wasm-interpreter, use WASM_UNREACHABLE instead of abort
* detect duplicate names in function names section
* detect duplicate export names
Diffstat (limited to 'src/wasm/wasm-s-parser.cpp')
-rw-r--r-- | src/wasm/wasm-s-parser.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/wasm/wasm-s-parser.cpp b/src/wasm/wasm-s-parser.cpp index 0263b2112..2290a4972 100644 --- a/src/wasm/wasm-s-parser.cpp +++ b/src/wasm/wasm-s-parser.cpp @@ -48,7 +48,7 @@ Element::List& Element::list() { } Element* Element::operator[](unsigned i) { - if (i >= list().size()) element_assert(0 && "expected more elements in list"); + if (i >= list().size()) throw ParseException("expected more elements in list", line, col); return list()[i]; } @@ -114,8 +114,10 @@ Element* SExpressionParser::parse() { } else if (input[0] == ')') { input++; auto last = curr; + if (stack.empty()) { + throw ParseException("s-expr stack empty"); + } curr = stack.back(); - assert(stack.size()); stack.pop_back(); curr->list().push_back(last); } else { |