summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai (kripken) <alonzakai@gmail.com>2017-01-01 16:10:38 -0800
committerAlon Zakai (kripken) <alonzakai@gmail.com>2017-01-04 17:33:52 -0800
commit649bbfc66fff32bf2bb34eec2106e28a4adef585 (patch)
treeaa90e18312b00bcdce494482f2b8da77a3b04e8c
parente1371b9c6ae1ad9a7e758f43af4d56def1f331d3 (diff)
downloadbinaryen-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.cpp3
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];
}