summaryrefslogtreecommitdiff
path: root/src/wasm-s-parser.h
diff options
context:
space:
mode:
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) {