Index: src/wasm/function-body-decoder.cc |
diff --git a/src/wasm/function-body-decoder.cc b/src/wasm/function-body-decoder.cc |
index 152fba1ffe92a42b9cd27c05f1180134cde89ef9..c48ad31136e517bddda3b37b652fa707a4be7db6 100644 |
--- a/src/wasm/function-body-decoder.cc |
+++ b/src/wasm/function-body-decoder.cc |
@@ -1112,6 +1112,10 @@ class WasmFullDecoder : public WasmDecoder { |
len = DecodeStoreMem(kWasmF64, MachineType::Float64()); |
break; |
case kExprGrowMemory: { |
+ if (!module_->has_memory) { |
titzer
2017/01/18 10:17:30
Can you factor out a little helper to turn this in
rossberg
2017/01/18 11:28:09
Done.
|
+ error(pc_ - 1, "memory instruction with no memory"); |
+ break; |
+ } |
MemoryIndexOperand operand(this, pc_); |
DCHECK_NOT_NULL(module_); |
if (module_->origin != kAsmJsOrigin) { |
@@ -1124,6 +1128,10 @@ class WasmFullDecoder : public WasmDecoder { |
break; |
} |
case kExprMemorySize: { |
+ if (!module_->has_memory) { |
+ error(pc_ - 1, "memory instruction with no memory"); |
+ break; |
+ } |
MemoryIndexOperand operand(this, pc_); |
Push(kWasmI32, BUILD(CurrentMemoryPages)); |
len = 1 + operand.length; |
@@ -1304,6 +1312,10 @@ class WasmFullDecoder : public WasmDecoder { |
void PopControl() { control_.pop_back(); } |
int DecodeLoadMem(ValueType type, MachineType mem_type) { |
+ if (!module_->has_memory) { |
+ error(pc_ - 1, "load instruction with no memory"); |
+ return 0; |
+ } |
MemoryAccessOperand operand(this, pc_, |
ElementSizeLog2Of(mem_type.representation())); |
@@ -1315,6 +1327,10 @@ class WasmFullDecoder : public WasmDecoder { |
} |
int DecodeStoreMem(ValueType type, MachineType mem_type) { |
+ if (!module_->has_memory) { |
+ error(pc_ - 1, "store instruction with no memory"); |
+ return 0; |
+ } |
MemoryAccessOperand operand(this, pc_, |
ElementSizeLog2Of(mem_type.representation())); |
Value val = Pop(1, type); |