From eb0ce0ea23ae6d74da3d2d805faf37ce8aeb8b8e Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Fri, 3 Jun 2016 13:29:29 -0700 Subject: check locals in s-parser --- src/wasm-s-parser.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src') 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) { -- cgit v1.2.3