diff options
author | Thomas Lively <tlively@google.com> | 2024-06-18 18:35:30 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-18 18:35:30 -0700 |
commit | eceb0fb6ac097e262bf74dcdb686cfc5d4c55188 (patch) | |
tree | 305ec69254bc6d09de771ba2e94c572f280176db | |
parent | 02c4c3cd43a2033a7fd2f5c75f6d92ac9b80bb4b (diff) | |
download | binaryen-eceb0fb6ac097e262bf74dcdb686cfc5d4c55188.tar.gz binaryen-eceb0fb6ac097e262bf74dcdb686cfc5d4c55188.tar.bz2 binaryen-eceb0fb6ac097e262bf74dcdb686cfc5d4c55188.zip |
Check malformed mutability on imported globals (#6679)
And re-enable the globals.wast spec test, which checks this.
-rw-r--r-- | scripts/test/shared.py | 1 | ||||
-rw-r--r-- | src/wasm/wasm-binary.cpp | 3 |
2 files changed, 3 insertions, 1 deletions
diff --git a/scripts/test/shared.py b/scripts/test/shared.py index 665ad6b7c..76d6fd568 100644 --- a/scripts/test/shared.py +++ b/scripts/test/shared.py @@ -400,7 +400,6 @@ os.chdir(options.out_dir) # expected-output/ if any. SPEC_TESTS_TO_SKIP = [ # Malformed module accepted - 'globals.wast', 'binary-leb128.wast', 'utf8-custom-section-id.wast', 'utf8-import-field.wast', diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp index 01b3602eb..cd1ca7dfd 100644 --- a/src/wasm/wasm-binary.cpp +++ b/src/wasm/wasm-binary.cpp @@ -2591,6 +2591,9 @@ void WasmBinaryReader::readImports() { Name name(std::string("gimport$") + std::to_string(globalCounter++)); auto type = getConcreteType(); auto mutable_ = getU32LEB(); + if (mutable_ & ~1) { + throwError("Global mutability must be 0 or 1"); + } auto curr = builder.makeGlobal(name, type, |