summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2021-05-13 11:31:04 -0700
committerGitHub <noreply@github.com>2021-05-13 11:31:04 -0700
commit284a47cbe888a3421d6f20f2bda716ae1ece097b (patch)
treede90f37950070c70ccfa8d57c96f6e5f19da3ed7 /src
parent665718a208786238633192d706c5cd61d4f5ad05 (diff)
downloadbinaryen-284a47cbe888a3421d6f20f2bda716ae1ece097b.tar.gz
binaryen-284a47cbe888a3421d6f20f2bda716ae1ece097b.tar.bz2
binaryen-284a47cbe888a3421d6f20f2bda716ae1ece097b.zip
RemoveUnusedModuleElements: The start function may be imported (#3884)
Without this fix we can segfault, as it has no body. Fixes #3879
Diffstat (limited to 'src')
-rw-r--r--src/passes/RemoveUnusedModuleElements.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/passes/RemoveUnusedModuleElements.cpp b/src/passes/RemoveUnusedModuleElements.cpp
index 59d9a2a9b..a26fd5d45 100644
--- a/src/passes/RemoveUnusedModuleElements.cpp
+++ b/src/passes/RemoveUnusedModuleElements.cpp
@@ -150,7 +150,7 @@ struct RemoveUnusedModuleElements : public Pass {
if (module->start.is()) {
auto startFunction = module->getFunction(module->start);
// Can be skipped if the start function is empty.
- if (startFunction->body->is<Nop>()) {
+ if (!startFunction->imported() && startFunction->body->is<Nop>()) {
module->start.clear();
} else {
roots.emplace_back(ModuleElementKind::Function, module->start);