summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/wasm/wasm-binary.cpp3
-rw-r--r--src/wasm/wasm-stack.cpp2
2 files changed, 4 insertions, 1 deletions
diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp
index 2b8c06c0b..9fe046c27 100644
--- a/src/wasm/wasm-binary.cpp
+++ b/src/wasm/wasm-binary.cpp
@@ -1090,6 +1090,9 @@ Type WasmBinaryBuilder::getType() {
// Single value types are negative; signature indices are non-negative
if (type >= 0) {
// TODO: Handle block input types properly
+ if (size_t(type) >= signatures.size()) {
+ throwError("invalid signature index: " + std::to_string(type));
+ }
return signatures[type].results;
}
switch (type) {
diff --git a/src/wasm/wasm-stack.cpp b/src/wasm/wasm-stack.cpp
index df9ad8620..3c162a9d5 100644
--- a/src/wasm/wasm-stack.cpp
+++ b/src/wasm/wasm-stack.cpp
@@ -23,7 +23,7 @@ void BinaryInstWriter::emitResultType(Type type) {
if (type == Type::unreachable) {
o << binaryType(Type::none);
} else if (type.isMulti()) {
- o << U32LEB(parent.getTypeIndex(Signature(Type::none, type)));
+ o << S32LEB(parent.getTypeIndex(Signature(Type::none, type)));
} else {
o << binaryType(type);
}