summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2017-07-19 11:33:23 -0700
committerDerek Schuff <dschuff@chromium.org>2017-07-19 11:33:23 -0700
commitfa5165bb52fae9742ebcbb224ec7907b8d914d21 (patch)
treed8a25df13da840a3ee6166974f83d3152679d1ac
parent0b2122d49a28f199ef7fde247e7e7a14829fa96e (diff)
downloadbinaryen-fa5165bb52fae9742ebcbb224ec7907b8d914d21.tar.gz
binaryen-fa5165bb52fae9742ebcbb224ec7907b8d914d21.tar.bz2
binaryen-fa5165bb52fae9742ebcbb224ec7907b8d914d21.zip
improve WasmValidator::validateMemBytes, check for unreasonable sizes even type is unreachable (#1102)
-rw-r--r--src/wasm/wasm-validator.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/wasm/wasm-validator.cpp b/src/wasm/wasm-validator.cpp
index 5ca6b2783..aaf5a7fd5 100644
--- a/src/wasm/wasm-validator.cpp
+++ b/src/wasm/wasm-validator.cpp
@@ -262,16 +262,16 @@ void WasmValidator::visitAtomicCmpxchg(AtomicCmpxchg* curr) {
shouldBeIntOrUnreachable(curr->expected->type, curr, "Atomic operations are only valid on int types");
}
void WasmValidator::validateMemBytes(uint8_t bytes, WasmType type, Expression* curr) {
- if (type == unreachable) {
- return; // nothing to validate in this case
- }
switch (bytes) {
case 1:
case 2:
- case 4:
- break;
+ case 4: break;
case 8: {
- shouldBeEqual(getWasmTypeSize(type), 8U, curr, "8-byte mem operations are only allowed with 8-byte wasm types");
+ // if we have a concrete type for the load, then we know the size of the mem operation and
+ // can validate it
+ if (type != unreachable) {
+ shouldBeEqual(getWasmTypeSize(type), 8U, curr, "8-byte mem operations are only allowed with 8-byte wasm types");
+ }
break;
}
default: fail("Memory operations must be 1,2,4, or 8 bytes", curr);