summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2021-07-30 09:59:52 -0700
committerGitHub <noreply@github.com>2021-07-30 09:59:52 -0700
commit57138f8cf94f0a55b615be9802ce76f6a6858f22 (patch)
treeaecc99dcdf8679c15d3a9c20417c9a5af2fc5be7 /src
parent30ff262c916933a852805fe4acf07e5d7f34891c (diff)
downloadbinaryen-57138f8cf94f0a55b615be9802ce76f6a6858f22.tar.gz
binaryen-57138f8cf94f0a55b615be9802ce76f6a6858f22.tar.bz2
binaryen-57138f8cf94f0a55b615be9802ce76f6a6858f22.zip
Do not crash in ExtractFunction if an export already exists (#4040)
We just cleared the list of exports, but the exportMap was still populated, so the data was in an inconsistent state. This fixes the case of running --extract-function multiple times on a file (which is usually not useful, unless one of the passes you are debugging adds new functions to the file - which some do).
Diffstat (limited to 'src')
-rw-r--r--src/passes/ExtractFunction.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/passes/ExtractFunction.cpp b/src/passes/ExtractFunction.cpp
index a219000c8..0c0c1477e 100644
--- a/src/passes/ExtractFunction.cpp
+++ b/src/passes/ExtractFunction.cpp
@@ -46,6 +46,7 @@ static void extract(PassRunner* runner, Module* module, Name name) {
// Leave just one export, for the thing we want.
module->exports.clear();
+ module->updateMaps();
module->addExport(Builder::makeExport(name, name, ExternalKind::Function));
// Remove unneeded things.