diff options
author | Alon Zakai <azakai@google.com> | 2023-01-10 10:46:02 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-10 10:46:02 -0800 |
commit | 82e3eff9742c92e13aef25035b40488f5339618d (patch) | |
tree | 986336b1258d6d1035430e2531fd0f58467b97e1 /src | |
parent | a803a0830586aaa3e9c989403881298b430f312c (diff) | |
download | binaryen-82e3eff9742c92e13aef25035b40488f5339618d.tar.gz binaryen-82e3eff9742c92e13aef25035b40488f5339618d.tar.bz2 binaryen-82e3eff9742c92e13aef25035b40488f5339618d.zip |
Fix iterator invalidation bug in GlobalStructInference (#5414)
Fixes #5406
Diffstat (limited to 'src')
-rw-r--r-- | src/passes/GlobalStructInference.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/passes/GlobalStructInference.cpp b/src/passes/GlobalStructInference.cpp index 901a51a9f..89ab155f8 100644 --- a/src/passes/GlobalStructInference.cpp +++ b/src/passes/GlobalStructInference.cpp @@ -157,7 +157,9 @@ struct GlobalStructInference : public Pass { // unoptimizable type makes all its supertypes unoptimizable as well. // TODO: this could be specific per field (and not all supers have all // fields) - for (auto type : unoptimizable) { + // Iterate on a copy to avoid invalidation as we insert. + auto unoptimizableCopy = unoptimizable; + for (auto type : unoptimizableCopy) { while (1) { unoptimizable.insert(type); |