Skip to content

Commit 00dd3b9

Browse files
committed
fix validation of memBytes, if the load type is unreachable, we can't and shouldn't try to validate
1 parent 29cf873 commit 00dd3b9

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/wasm-validator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ struct WasmValidator : public PostWalker<WasmValidator> {
217217

218218
void validateAlignment(size_t align, WasmType type, Index bytes, bool isAtomic,
219219
Expression* curr);
220-
void validateMemBytes(uint8_t bytes, WasmType ty, Expression* curr);
220+
void validateMemBytes(uint8_t bytes, WasmType type, Expression* curr);
221221
void validateBinaryenIR(Module& wasm);
222222
};
223223

src/wasm/wasm-validator.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,14 +237,17 @@ void WasmValidator::visitAtomicRMW(AtomicRMW* curr) {
237237
void WasmValidator::visitAtomicCmpxchg(AtomicCmpxchg* curr) {
238238
validateMemBytes(curr->bytes, curr->type, curr);
239239
}
240-
void WasmValidator::validateMemBytes(uint8_t bytes, WasmType ty, Expression* curr) {
240+
void WasmValidator::validateMemBytes(uint8_t bytes, WasmType type, Expression* curr) {
241+
if (type == unreachable) {
242+
return; // nothing to validate in this case
243+
}
241244
switch (bytes) {
242245
case 1:
243246
case 2:
244247
case 4:
245248
break;
246249
case 8: {
247-
shouldBeEqual(getWasmTypeSize(ty), 8U, curr, "8-byte mem operations are only allowed with 8-byte wasm types");
250+
shouldBeEqual(getWasmTypeSize(type), 8U, curr, "8-byte mem operations are only allowed with 8-byte wasm types");
248251
break;
249252
}
250253
default: fail("Memory operations must be 1,2,4, or 8 bytes", curr);

0 commit comments

Comments
 (0)