summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJérôme Vouillon <jerome.vouillon@gmail.com>2024-03-27 14:58:31 -0400
committerGitHub <noreply@github.com>2024-03-27 18:58:31 +0000
commit61877e9bbc6df38d3bb342a695ead0bc290fbb40 (patch)
treeb9bfe212d269c8bb1c149b23108399c7a6964070 /src
parentfafbb4c442d872de4e991ab37bd290f012678ff9 (diff)
downloadbinaryen-61877e9bbc6df38d3bb342a695ead0bc290fbb40.tar.gz
binaryen-61877e9bbc6df38d3bb342a695ead0bc290fbb40.tar.bz2
binaryen-61877e9bbc6df38d3bb342a695ead0bc290fbb40.zip
Fix parsing of table imports (#6446)
The types was ignored and funcref was always used instead.
Diffstat (limited to 'src')
-rw-r--r--src/wasm/wasm-s-parser.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/wasm/wasm-s-parser.cpp b/src/wasm/wasm-s-parser.cpp
index d6df7ab0f..c7cedfdbd 100644
--- a/src/wasm/wasm-s-parser.cpp
+++ b/src/wasm/wasm-s-parser.cpp
@@ -3737,10 +3737,13 @@ void SExpressionWasmBuilder::parseImport(Element& s) {
table->max = Table::kUnlimitedSize;
}
- wasm.addTable(std::move(table));
-
- j++; // funcref
// ends with the table element type
+ table->type = elementToType(*inner[j++]);
+ if (!table->type.isRef()) {
+ throw SParseException("Only reference types are valid for tables", s);
+ }
+
+ wasm.addTable(std::move(table));
} else if (kind == ExternalKind::Memory) {
auto memory = std::make_unique<Memory>();
memory->setName(name, hasExplicitName);