diff options
author | Alon Zakai <azakai@google.com> | 2021-01-08 16:54:24 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-08 08:54:24 -0800 |
commit | b266279cd393378bceab52e06b7b8bd0a5d7a80b (patch) | |
tree | c6bd7f225ca42a52a2a062754ad94ddb944ecf76 /src | |
parent | b7e4ec5a39b3f0d5a416b50bad2477c60969437f (diff) | |
download | binaryen-b266279cd393378bceab52e06b7b8bd0a5d7a80b.tar.gz binaryen-b266279cd393378bceab52e06b7b8bd0a5d7a80b.tar.bz2 binaryen-b266279cd393378bceab52e06b7b8bd0a5d7a80b.zip |
[GC] Validate that struct.set is to a mutable field. (#3473)
This required a few test fixes, to ensure we don't have invalid wasts with
writes to immutable fields.
Diffstat (limited to 'src')
-rw-r--r-- | src/wasm/wasm-validator.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/wasm/wasm-validator.cpp b/src/wasm/wasm-validator.cpp index 06f77b093..bf6e121bf 100644 --- a/src/wasm/wasm-validator.cpp +++ b/src/wasm/wasm-validator.cpp @@ -2336,10 +2336,13 @@ void FunctionValidator::visitStructSet(StructSet* curr) { if (curr->ref->type != Type::unreachable) { const auto& fields = curr->ref->type.getHeapType().getStruct().fields; shouldBeTrue(curr->index < fields.size(), curr, "bad struct.get field"); + auto& field = fields[curr->index]; shouldBeEqual(curr->value->type, - fields[curr->index].type, + field.type, curr, "struct.set must have the proper type"); + shouldBeEqual( + field.mutable_, Mutable, curr, "struct.set field must be mutable"); } } |