]> granicus.if.org Git - clang/commitdiff
Fix a use-after-free bug I recently introduced in lookupModuleFile
authorBen Langmuir <blangmuir@apple.com>
Sun, 4 May 2014 05:20:54 +0000 (05:20 +0000)
committerBen Langmuir <blangmuir@apple.com>
Sun, 4 May 2014 05:20:54 +0000 (05:20 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@207932 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Serialization/ModuleManager.cpp

index 9b3159e1705af610788e7e682f4f72fc60fe68fb..66f18158a69d10fe080367d35652384cbe0b9235 100644 (file)
@@ -390,11 +390,10 @@ bool ModuleManager::lookupModuleFile(StringRef FileName,
   }
 
   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;
 }