summaryrefslogtreecommitdiff
path: root/src/wasm/wasm-binary.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/wasm/wasm-binary.cpp')
-rw-r--r--src/wasm/wasm-binary.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp
index ac68cbe56..187328e58 100644
--- a/src/wasm/wasm-binary.cpp
+++ b/src/wasm/wasm-binary.cpp
@@ -967,6 +967,9 @@ void WasmBinaryBuilder::readSignatures() {
}
Name WasmBinaryBuilder::getFunctionIndexName(Index i) {
+ if (i >= wasm.functions.size()) {
+ throwError("invalid function index");
+ }
return wasm.functions[i]->name;
}
@@ -1505,9 +1508,6 @@ void WasmBinaryBuilder::processFunctions() {
auto index = exportIndexes[curr];
switch (curr->kind) {
case ExternalKind::Function: {
- if (index >= wasm.functions.size()) {
- throwError("bad function export index");
- }
curr->value = getFunctionIndexName(index);
break;
}