Skip to content

Commit fa5165b

Browse files
kripkendschuff
authored andcommitted
improve WasmValidator::validateMemBytes, check for unreasonable sizes even type is unreachable (#1102)
1 parent 0b2122d commit fa5165b

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

src/wasm/wasm-validator.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -262,16 +262,16 @@ void WasmValidator::visitAtomicCmpxchg(AtomicCmpxchg* curr) {
262262
shouldBeIntOrUnreachable(curr->expected->type, curr, "Atomic operations are only valid on int types");
263263
}
264264
void WasmValidator::validateMemBytes(uint8_t bytes, WasmType type, Expression* curr) {
265-
if (type == unreachable) {
266-
return; // nothing to validate in this case
267-
}
268265
switch (bytes) {
269266
case 1:
270267
case 2:
271-
case 4:
272-
break;
268+
case 4: break;
273269
case 8: {
274-
shouldBeEqual(getWasmTypeSize(type), 8U, curr, "8-byte mem operations are only allowed with 8-byte wasm types");
270+
// if we have a concrete type for the load, then we know the size of the mem operation and
271+
// can validate it
272+
if (type != unreachable) {
273+
shouldBeEqual(getWasmTypeSize(type), 8U, curr, "8-byte mem operations are only allowed with 8-byte wasm types");
274+
}
275275
break;
276276
}
277277
default: fail("Memory operations must be 1,2,4, or 8 bytes", curr);

0 commit comments

Comments
 (0)