r242960 - Fix dumb use-after-free bug introduced in r242868.

Richard Smith richard-llvm at metafoo.co.uk
Wed Jul 22 15:51:15 PDT 2015


Author: rsmith
Date: Wed Jul 22 17:51:15 2015
New Revision: 242960

URL: http://llvm.org/viewvc/llvm-project?rev=242960&view=rev
Log:
Fix dumb use-after-free bug introduced in r242868.

Modified:
    cfe/trunk/lib/Serialization/ModuleManager.cpp

Modified: cfe/trunk/lib/Serialization/ModuleManager.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ModuleManager.cpp?rev=242960&r1=242959&r2=242960&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ModuleManager.cpp (original)
+++ cfe/trunk/lib/Serialization/ModuleManager.cpp Wed Jul 22 17:51:15 2015
@@ -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





More information about the cfe-commits mailing list