diff options
author | Alon Zakai <alonzakai@gmail.com> | 2019-01-24 13:12:36 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-24 13:12:36 -0800 |
commit | 85e95e315a8023c46eb804fe80ebc244bcfdae3e (patch) | |
tree | bf61cd8ef492053500f3e47d5dde73d86890f447 /src/wasm/wasm-binary.cpp | |
parent | 119525ea6078c9af697de0038407ab541f3d4c12 (diff) | |
download | binaryen-85e95e315a8023c46eb804fe80ebc244bcfdae3e.tar.gz binaryen-85e95e315a8023c46eb804fe80ebc244bcfdae3e.tar.bz2 binaryen-85e95e315a8023c46eb804fe80ebc244bcfdae3e.zip |
validate all function indexes in binary reading (#1887)
fixes bug reported in comment on e63c4a7 , #1885 (comment) , #1879 (comment)
Diffstat (limited to 'src/wasm/wasm-binary.cpp')
-rw-r--r-- | src/wasm/wasm-binary.cpp | 6 |
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; } |