diff options
author | Alon Zakai <alonzakai@gmail.com> | 2016-08-09 11:54:31 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2016-09-07 09:54:57 -0700 |
commit | 0b6faf409ff92f6c4f81b5dd2474f43a4238878c (patch) | |
tree | 0cb1378ca8abdf23c66475f54503488bb08c6bf7 /src/wasm-s-parser.h | |
parent | ef82c858b9ca6e1a9e34e79398195e7b549507aa (diff) | |
download | binaryen-0b6faf409ff92f6c4f81b5dd2474f43a4238878c.tar.gz binaryen-0b6faf409ff92f6c4f81b5dd2474f43a4238878c.tar.bz2 binaryen-0b6faf409ff92f6c4f81b5dd2474f43a4238878c.zip |
throw a parse error on bad result arities
Diffstat (limited to 'src/wasm-s-parser.h')
-rw-r--r-- | src/wasm-s-parser.h | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/wasm-s-parser.h b/src/wasm-s-parser.h index 28975c7e3..61ddbd48a 100644 --- a/src/wasm-s-parser.h +++ b/src/wasm-s-parser.h @@ -319,10 +319,11 @@ private: Element& curr = *s[i]; IString id = curr[0]->str(); if (id == RESULT) { + if (curr.size() > 2) throw ParseException("invalid result arity", curr.line, curr.col); functionTypes[name] = stringToWasmType(curr[1]->str()); } else if (id == TYPE) { Name typeName = curr[1]->str(); - if (!wasm.checkFunctionType(typeName)) throw ParseException("unknown function"); + if (!wasm.checkFunctionType(typeName)) throw ParseException("unknown function", curr.line, curr.col); type = wasm.getFunctionType(typeName); functionTypes[name] = type->result; } else if (id == PARAM && curr.size() > 1) { @@ -494,6 +495,7 @@ private: currLocalTypes[name] = type; } } else if (id == RESULT) { + if (curr.size() > 2) throw ParseException("invalid result arity", curr.line, curr.col); result = stringToWasmType(curr[1]->str()); } else if (id == TYPE) { Name name = curr[1]->str(); @@ -1505,6 +1507,7 @@ private: type->params.push_back(stringToWasmType(curr[j]->str())); } } else if (curr[0]->str() == RESULT) { + if (curr.size() > 2) throw ParseException("invalid result arity", curr.line, curr.col); type->result = stringToWasmType(curr[1]->str()); } } |