r207932 - Fix a use-after-free bug I recently introduced in lookupModuleFile

Ben Langmuir blangmuir at apple.com
Sat May 3 22:20:55 PDT 2014


Author: benlangmuir
Date: Sun May  4 00:20:54 2014
New Revision: 207932

URL: http://llvm.org/viewvc/llvm-project?rev=207932&view=rev
Log:
Fix a use-after-free bug I recently introduced in lookupModuleFile

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=207932&r1=207931&r2=207932&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ModuleManager.cpp (original)
+++ cfe/trunk/lib/Serialization/ModuleManager.cpp Sun May  4 00:20:54 2014
@@ -390,11 +390,10 @@ bool ModuleManager::lookupModuleFile(Str
   }
 
   if ((ExpectedSize && ExpectedSize != File->getSize()) ||
-      (ExpectedModTime && ExpectedModTime != File->getModificationTime())) {
-    FileMgr.invalidateCache(File);
-    File = nullptr;
+      (ExpectedModTime && ExpectedModTime != File->getModificationTime()))
+    // Do not destroy File, as it may be referenced. If we need to rebuild it,
+    // it will be destroyed by removeModules.
     return true;
-  }
 
   return false;
 }





More information about the cfe-commits mailing list