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

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

Issue 2447683004: [wasm] fix simd opcode read and error case for bad simd opcodes (Closed)
Patch Set: [wasm] fix simd opcode read and error case for bad simd opcodes Created 4 years, 2 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 4e19d0f6b6a1894851890ffb5bedbac1790f9c99..84b64d6d8ddf3d02306fbe94d6f1c90abbb17aae 100644
--- a/src/wasm/ast-decoder.cc
+++ b/src/wasm/ast-decoder.cc
@@ -324,7 +324,7 @@ class WasmDecoder : public Decoder {
case kExprF64Const:
return 9;
case kSimdPrefix: {
- byte simd_index = *(pc + 1);
+ byte simd_index = checked_read_u8(pc, 1, "simd_index");
WasmOpcode opcode =
static_cast<WasmOpcode>(kSimdPrefix << 8 | simd_index);
switch (opcode) {
@@ -341,7 +341,8 @@ class WasmDecoder : public Decoder {
return 3;
}
default:
- UNREACHABLE();
+ error("invalid SIMD opcode");
+ return 2;
}
}
default:
@@ -1139,7 +1140,7 @@ class WasmFullDecoder : public WasmDecoder {
case kSimdPrefix: {
CHECK_PROTOTYPE_OPCODE(wasm_simd_prototype);
len++;
- byte simd_index = *(pc_ + 1);
+ byte simd_index = checked_read_u8(pc_, 1, "simd index");
opcode = static_cast<WasmOpcode>(opcode << 8 | simd_index);
TRACE(" @%-4d #%02x #%02x:%-20s|", startrel(pc_), kSimdPrefix,
simd_index, WasmOpcodes::ShortOpcodeName(opcode));
« 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