]> granicus.if.org Git - clang/commitdiff
Fix use-after-free in ModuleManager
authorBen Langmuir <blangmuir@apple.com>
Wed, 21 Oct 2015 23:12:45 +0000 (23:12 +0000)
committerBen Langmuir <blangmuir@apple.com>
Wed, 21 Oct 2015 23:12:45 +0000 (23:12 +0000)
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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@250963 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Serialization/ModuleManager.cpp

index f9d0fa469b25af539598e41fcea234d23feb4ebb..74f75a103f7a7edc9e47713a1aa8f4f7a10584c7 100644 (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);