Skip to content

Commit

Permalink
Add binary format parse check for imported function types (#4423)
Browse files Browse the repository at this point in the history
Without this we hit an assertion later, which is less clear.

See #4413
  • Loading branch information
kripken authored Jan 5, 2022
1 parent d4da7d0 commit 1beec37
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/wasm/wasm-binary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2057,7 +2057,13 @@ void WasmBinaryBuilder::readImports() {
Name name(std::string("fimport$") + std::to_string(functionCounter++));
auto index = getU32LEB();
functionTypes.push_back(getTypeByIndex(index));
auto curr = builder.makeFunction(name, getTypeByIndex(index), {});
auto type = getTypeByIndex(index);
if (!type.isSignature()) {
throwError(std::string("Imported function ") + module.str + '.' +
base.str +
"'s type must be a signature. Given: " + type.toString());
}
auto curr = builder.makeFunction(name, type, {});
curr->module = module;
curr->base = base;
functionImports.push_back(curr.get());
Expand Down

0 comments on commit 1beec37

Please # to comment.