Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(303)

Unified Diff: src/wasm/ast-decoder.cc

Issue 1961853002: [wasm] Verify expressions do not cross control boundaries in WASM. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Add comment Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | test/unittests/wasm/ast-decoder-unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/wasm/ast-decoder.cc
diff --git a/src/wasm/ast-decoder.cc b/src/wasm/ast-decoder.cc
index 1432e152b084ceb9d1c6b1017dac97fadb9ec57f..427997e8b08d691e7f75f73f0cd574ca3763479d 100644
--- a/src/wasm/ast-decoder.cc
+++ b/src/wasm/ast-decoder.cc
@@ -487,9 +487,9 @@ class SR_WasmDecoder : public WasmDecoder {
SsaEnv* ssa_env_;
- ZoneVector<LocalType> local_type_vec_;
- ZoneVector<Value> stack_;
- ZoneVector<Control> control_;
+ ZoneVector<LocalType> local_type_vec_; // types of local variables.
+ ZoneVector<Value> stack_; // stack of values.
+ ZoneVector<Control> control_; // stack of blocks, loops, and ifs.
inline bool build() { return builder_ && ssa_env_->go(); }
@@ -1157,7 +1157,8 @@ class SR_WasmDecoder : public WasmDecoder {
}
Value Pop() {
- if (stack_.empty()) {
+ size_t limit = control_.empty() ? 0 : control_.back().stack_depth;
+ if (stack_.size() <= limit) {
Value val = {pc_, nullptr, kAstStmt};
error(pc_, pc_, "%s found empty stack", SafeOpcodeNameAt(pc_));
return val;
« no previous file with comments | « no previous file | test/unittests/wasm/ast-decoder-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698