From: Ben Langmuir Date: Sun, 4 May 2014 05:20:54 +0000 (+0000) Subject: Fix a use-after-free bug I recently introduced in lookupModuleFile X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=dbbd409b15bce1d29e6bb188f334efdbc6684d91;p=clang Fix a use-after-free bug I recently introduced in lookupModuleFile git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@207932 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Serialization/ModuleManager.cpp b/lib/Serialization/ModuleManager.cpp index 9b3159e170..66f18158a6 100644 --- a/lib/Serialization/ModuleManager.cpp +++ b/lib/Serialization/ModuleManager.cpp @@ -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; }