summaryrefslogtreecommitdiff
path: root/src/wasm-s-parser.h
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2016-06-03 13:29:29 -0700
committerAlon Zakai <alonzakai@gmail.com>2016-06-03 13:29:29 -0700
commiteb0ce0ea23ae6d74da3d2d805faf37ce8aeb8b8e (patch)
tree3809be13e73de14fe3921ab2fee026aa4113d82c /src/wasm-s-parser.h
parentcfc0029a95c8be562a595adb507b0aa171f01a31 (diff)
downloadbinaryen-eb0ce0ea23ae6d74da3d2d805faf37ce8aeb8b8e.tar.gz
binaryen-eb0ce0ea23ae6d74da3d2d805faf37ce8aeb8b8e.tar.bz2
binaryen-eb0ce0ea23ae6d74da3d2d805faf37ce8aeb8b8e.zip
check locals in s-parser
Diffstat (limited to 'src/wasm-s-parser.h')
-rw-r--r--src/wasm-s-parser.h10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/wasm-s-parser.h b/src/wasm-s-parser.h
index e6262c645..e0db65224 100644
--- a/src/wasm-s-parser.h
+++ b/src/wasm-s-parser.h
@@ -822,9 +822,15 @@ private:
}
Index getLocalIndex(Element& s) {
- if (s.dollared()) return currFunction->getLocalIndex(s.str());
+ if (s.dollared()) {
+ auto ret = s.str();
+ if (currFunction->localIndices.count(ret) == 0) throw ParseException("bad local name", s.line, s.col);
+ return currFunction->getLocalIndex(ret);
+ }
// this is a numeric index
- return atoi(s.c_str());
+ Index ret = atoi(s.c_str());
+ if (ret >= currFunction->getNumLocals()) throw ParseException("bad local index", s.line, s.col);
+ return ret;
}
Expression* makeGetLocal(Element& s) {