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

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

Issue 2493433002: [wasm] Only immutable imported globals are valid initializer expressions (Closed)
Patch Set: Removed another test Created 4 years, 1 month 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/cctest/wasm/test-run-wasm-module.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/wasm/module-decoder.cc
diff --git a/src/wasm/module-decoder.cc b/src/wasm/module-decoder.cc
index 8794fe64351ca17add7c44f5fa149f82796b0a82..272a60ddaa6383e3503c606352d9d77fb73b2faa 100644
--- a/src/wasm/module-decoder.cc
+++ b/src/wasm/module-decoder.cc
@@ -910,6 +910,21 @@ class ModuleDecoder : public Decoder {
switch (opcode) {
case kExprGetGlobal: {
GlobalIndexOperand operand(this, pc() - 1);
+ if (module->globals.size() <= operand.index) {
+ error("global index is out of bounds");
+ expr.kind = WasmInitExpr::kNone;
+ expr.val.i32_const = 0;
+ break;
+ }
+ WasmGlobal* global = &module->globals[operand.index];
+ if (global->mutability || !global->imported) {
+ error(
+ "only immutable imported globals can be used in initializer "
+ "expressions");
+ expr.kind = WasmInitExpr::kNone;
+ expr.val.i32_const = 0;
+ break;
+ }
expr.kind = WasmInitExpr::kGlobalIndex;
expr.val.global_index = operand.index;
len = operand.length;
« no previous file with comments | « no previous file | test/cctest/wasm/test-run-wasm-module.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698