aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Serialization/ModuleManager.cpp
diff options
context:
space:
mode:
authorBen Langmuir <blangmuir@apple.com>2015-10-21 23:12:45 +0000
committerBen Langmuir <blangmuir@apple.com>2015-10-21 23:12:45 +0000
commita50dbb2065b34ed27019dad21c22097b352f5b42 (patch)
tree1360bf5006c9c10d36de499e8874dc8a31350e98 /clang/lib/Serialization/ModuleManager.cpp
parent626beefd1ce702e3e4a3d9b63f7dcc88e72657ab (diff)
downloadllvm-a50dbb2065b34ed27019dad21c22097b352f5b42.zip
llvm-a50dbb2065b34ed27019dad21c22097b352f5b42.tar.gz
llvm-a50dbb2065b34ed27019dad21c22097b352f5b42.tar.bz2
Fix use-after-free in ModuleManager
When removing out-of-date modules we might have left behind a VisitOrder that contains pointers to freed ModuleFiles. This was very rarely seen, because it only happens when modules go out of date and the VisitOrder happens to have the right size to not be recomputed. Thanks ASan! rdar://23181512 llvm-svn: 250963
Diffstat (limited to 'clang/lib/Serialization/ModuleManager.cpp')
-rw-r--r--clang/lib/Serialization/ModuleManager.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/clang/lib/Serialization/ModuleManager.cpp b/clang/lib/Serialization/ModuleManager.cpp
index f9d0fa46..74f75a1 100644
--- a/clang/lib/Serialization/ModuleManager.cpp
+++ b/clang/lib/Serialization/ModuleManager.cpp
@@ -194,6 +194,9 @@ void ModuleManager::removeModules(
if (first == last)
return;
+ // Explicitly clear VisitOrder since we might not notice it is stale.
+ VisitOrder.clear();
+
// Collect the set of module file pointers that we'll be removing.
llvm::SmallPtrSet<ModuleFile *, 4> victimSet(first, last);