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
This commit is contained in:
Ben Langmuir
2015-10-21 23:12:45 +00:00
parent 626beefd1c
commit a50dbb2065

View File

@@ -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);