diff options
author | Alon Zakai <azakai@google.com> | 2020-04-08 09:43:35 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-08 09:43:35 -0700 |
commit | 0a44e995d9b09812260ca46add0f823820d4cc31 (patch) | |
tree | 3737802336b8158335dc3201cd9fdd846c1315a4 /src | |
parent | 7531e7b46c2889bd8a1cbe9227a1e306f6c7c0aa (diff) | |
download | binaryen-0a44e995d9b09812260ca46add0f823820d4cc31.tar.gz binaryen-0a44e995d9b09812260ca46add0f823820d4cc31.tar.bz2 binaryen-0a44e995d9b09812260ca46add0f823820d4cc31.zip |
Fix ReorderLocals handling of local names (#2728)
I think the history here is that localNames used to be a
vector, then we made it a map, but didn't update this pass...
so in rare cases it could end up emitting wrong stuff.
Diffstat (limited to 'src')
-rw-r--r-- | src/passes/ReorderLocals.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/passes/ReorderLocals.cpp b/src/passes/ReorderLocals.cpp index 9eea0b73c..7b4c99e78 100644 --- a/src/passes/ReorderLocals.cpp +++ b/src/passes/ReorderLocals.cpp @@ -132,8 +132,9 @@ struct ReorderLocals : public WalkerPass<PostWalker<ReorderLocals>> { curr->localNames.clear(); curr->localIndices.clear(); for (size_t i = 0; i < newToOld.size(); i++) { - if (newToOld[i] < oldLocalNames.size()) { - auto old = oldLocalNames[newToOld[i]]; + auto iter = oldLocalNames.find(newToOld[i]); + if (iter != oldLocalNames.end()) { + auto old = iter->second; curr->localNames[i] = old; curr->localIndices[old] = i; } |