Chromium Code Reviews| Index: src/wasm/module-decoder.cc |
| diff --git a/src/wasm/module-decoder.cc b/src/wasm/module-decoder.cc |
| index 9ba0b3b663f5bdd5c8e6f53861272faeb83d05ab..777acdfb1c043f1f10a62579c986c9f944b2587f 100644 |
| --- a/src/wasm/module-decoder.cc |
| +++ b/src/wasm/module-decoder.cc |
| @@ -60,6 +60,22 @@ class ModuleDecoder : public Decoder { |
| bool sections[kMaxModuleSectionCode]; |
| memset(sections, 0, sizeof(sections)); |
| + const byte* pos = pc_; |
| + uint32_t magic_number = consume_u32("wasm magic"); |
| + if (magic_number != kWasmMagic) { |
| + error(pos, pos, "expected magic bytes 0 a s m"); |
|
JF
2016/02/27 19:43:04
"0 a s m" will be incorrect if we change kWasmMagi
titzer
2016/02/27 23:05:09
Done.
|
| + return toResult(module); |
| + } |
| + |
| + pos = pc_; |
| + uint32_t magic_version = consume_u32("wasm version"); |
| + if (magic_version != kWasmVersion) { |
| + error(pos, pos, "expected version %02x %02x %02x %02x", |
| + (kWasmVersion & 0xff), (kWasmVersion >> 8) & 0xff, |
| + (kWasmVersion >> 16) & 0xff, (kWasmVersion >> 24) & 0xff); |
|
JF
2016/02/27 19:43:04
Same here, print magic_version.
titzer
2016/02/27 23:05:09
Done.
|
| + return toResult(module); |
| + } |
| + |
| // Decode the module sections. |
| while (pc_ < limit_) { |
| TRACE("DecodeSection\n"); |