diff options
author | Alon Zakai (kripken) <alonzakai@gmail.com> | 2017-01-01 16:10:38 -0800 |
---|---|---|
committer | Alon Zakai (kripken) <alonzakai@gmail.com> | 2017-01-04 17:33:52 -0800 |
commit | 649bbfc66fff32bf2bb34eec2106e28a4adef585 (patch) | |
tree | aa90e18312b00bcdce494482f2b8da77a3b04e8c | |
parent | e1371b9c6ae1ad9a7e758f43af4d56def1f331d3 (diff) | |
download | binaryen-649bbfc66fff32bf2bb34eec2106e28a4adef585.tar.gz binaryen-649bbfc66fff32bf2bb34eec2106e28a4adef585.tar.bz2 binaryen-649bbfc66fff32bf2bb34eec2106e28a4adef585.zip |
handle a module which has no globals at all
-rw-r--r-- | src/wasm/wasm-binary.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp index 55f85b4b5..26da1487f 100644 --- a/src/wasm/wasm-binary.cpp +++ b/src/wasm/wasm-binary.cpp @@ -906,7 +906,7 @@ void WasmBinaryBuilder::read() { // imports can read global imports, so we run getGlobalName and create the mapping // but after we read globals, we need to add the internal globals too, so do that here mappedGlobals.clear(); // wipe the mapping - getGlobalName(0); // force rebuild + getGlobalName(-1); // force rebuild break; } case BinaryConsts::Section::Data: readDataSegments(); break; @@ -1358,6 +1358,7 @@ Name WasmBinaryBuilder::getGlobalName(Index index) { mappedGlobals[index] = wasm.globals[i]->name; } } + if (index == Index(-1)) return Name("null"); // just a force-rebuild assert(mappedGlobals.count(index)); return mappedGlobals[index]; } |