summaryrefslogtreecommitdiff
path: root/src/binary-reader-interpreter.cc
diff options
context:
space:
mode:
authorSam Clegg <sbc@chromium.org>2017-08-31 17:40:40 -0700
committerGitHub <noreply@github.com>2017-08-31 17:40:40 -0700
commitcd9f0a60b5c869673a843f1c0ff47068661b5440 (patch)
tree7d15efd724484f9b84cd7ee2ef36daea47f54c85 /src/binary-reader-interpreter.cc
parent03a3c76144192dcc53826ba1cefb35c6502e407e (diff)
downloadwabt-cd9f0a60b5c869673a843f1c0ff47068661b5440.tar.gz
wabt-cd9f0a60b5c869673a843f1c0ff47068661b5440.tar.bz2
wabt-cd9f0a60b5c869673a843f1c0ff47068661b5440.zip
Add type check to data segment offset (#525)
This is a conservative check that we can do in the binary reader itself. More extensive checking is still done in the interpreter (i.e. vefiying the type of the global).
Diffstat (limited to 'src/binary-reader-interpreter.cc')
-rw-r--r--src/binary-reader-interpreter.cc12
1 files changed, 2 insertions, 10 deletions
diff --git a/src/binary-reader-interpreter.cc b/src/binary-reader-interpreter.cc
index a5086c78..4cac588f 100644
--- a/src/binary-reader-interpreter.cc
+++ b/src/binary-reader-interpreter.cc
@@ -973,11 +973,7 @@ wabt::Result BinaryReaderInterpreter::OnStartFunction(Index func_index) {
}
wabt::Result BinaryReaderInterpreter::EndElemSegmentInitExpr(Index index) {
- if (init_expr_value.type != Type::I32) {
- PrintError("type mismatch in elem segment, expected i32 but got %s",
- GetTypeName(init_expr_value.type));
- return wabt::Result::Error;
- }
+ assert(init_expr_value.type == Type::I32);
table_offset = init_expr_value.value.i32;
return wabt::Result::Ok;
}
@@ -1010,11 +1006,7 @@ wabt::Result BinaryReaderInterpreter::OnDataSegmentData(Index index,
Address size) {
assert(module->memory_index != kInvalidIndex);
Memory* memory = env->GetMemory(module->memory_index);
- if (init_expr_value.type != Type::I32) {
- PrintError("type mismatch in data segment, expected i32 but got %s",
- GetTypeName(init_expr_value.type));
- return wabt::Result::Error;
- }
+ assert(init_expr_value.type == Type::I32);
Address address = init_expr_value.value.i32;
uint64_t end_address =
static_cast<uint64_t>(address) + static_cast<uint64_t>(size);