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

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

Issue 2493433002: [wasm] Only immutable imported globals are valid initializer expressions (Closed)
Patch Set: 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/unittests/wasm/module-decoder-unittest.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..857d1302ce59945075117129b111fe079aebcef4 100644
--- a/src/wasm/module-decoder.cc
+++ b/src/wasm/module-decoder.cc
@@ -910,6 +910,25 @@ class ModuleDecoder : public Decoder {
switch (opcode) {
case kExprGetGlobal: {
GlobalIndexOperand operand(this, pc() - 1);
+ if (module->globals.size() <= operand.index) {
+ printf("error\n");
titzer 2016/11/09 13:26:43 stray printfs remaining here
ahaas 2016/11/09 14:21:16 Removed.
+ 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 || global->mutability || !global->imported) {
titzer 2016/11/09 13:26:43 I don't think that !global can ever be true.
ahaas 2016/11/09 14:21:16 Removed.
+ printf("error\n");
+ error(
+ "only immutable imported globals can be used in initializer "
+ "expressions");
+ expr.kind = WasmInitExpr::kNone;
+ expr.val.i32_const = 0;
+ break;
+ } else {
+ printf("passed\n");
+ }
expr.kind = WasmInitExpr::kGlobalIndex;
expr.val.global_index = operand.index;
len = operand.length;
« no previous file with comments | « no previous file | test/unittests/wasm/module-decoder-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698