diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2015-07-22 22:51:15 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2015-07-22 22:51:15 +0000 |
commit | 16fe4d178e9d81b07e8deb59a4b4292850364898 (patch) | |
tree | b70292b91849bab074c5800718890e3d8517b42d /clang/lib/Serialization/ModuleManager.cpp | |
parent | 00f512ebdf3e40969b135c4241421d218d37a71f (diff) | |
download | llvm-16fe4d178e9d81b07e8deb59a4b4292850364898.zip llvm-16fe4d178e9d81b07e8deb59a4b4292850364898.tar.gz llvm-16fe4d178e9d81b07e8deb59a4b4292850364898.tar.bz2 |
Fix dumb use-after-free bug introduced in r242868.
llvm-svn: 242960
Diffstat (limited to 'clang/lib/Serialization/ModuleManager.cpp')
-rw-r--r-- | clang/lib/Serialization/ModuleManager.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/clang/lib/Serialization/ModuleManager.cpp b/clang/lib/Serialization/ModuleManager.cpp index 254e8e6..dbdd945 100644 --- a/clang/lib/Serialization/ModuleManager.cpp +++ b/clang/lib/Serialization/ModuleManager.cpp @@ -207,6 +207,15 @@ void ModuleManager::removeModules( Roots.erase(std::remove_if(Roots.begin(), Roots.end(), IsVictim), Roots.end()); + // Remove the modules from the PCH chain. + for (auto I = first; I != last; ++I) { + if (!(*I)->isModule()) { + PCHChain.erase(std::find(PCHChain.begin(), PCHChain.end(), *I), + PCHChain.end()); + break; + } + } + // Delete the modules and erase them from the various structures. for (ModuleIterator victim = first; victim != last; ++victim) { Modules.erase((*victim)->File); @@ -229,15 +238,6 @@ void ModuleManager::removeModules( // Remove the modules from the chain. Chain.erase(first, last); - - // Also remove them from the PCH chain. - for (auto I = first; I != last; ++I) { - if (!(*I)->isModule()) { - PCHChain.erase(std::find(PCHChain.begin(), PCHChain.end(), *I), - PCHChain.end()); - break; - } - } } void |