Skip to content

Commit

Permalink
validate all function indexes in binary reading (#1887)
Browse files Browse the repository at this point in the history
fixes bug reported in comment on e63c4a7 , #1885 (comment) , #1879 (comment)
  • Loading branch information
kripken committed Jan 24, 2019
1 parent 119525e commit 85e95e3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/wasm/wasm-binary.cpp
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 85e95e3

Please sign in to comment.