r203140 - Fix use-after-free detected by ASan bootstrap.
Richard Smith
richard-llvm at metafoo.co.uk
Thu Mar 6 10:08:09 PST 2014
Author: rsmith
Date: Thu Mar 6 12:08:08 2014
New Revision: 203140
URL: http://llvm.org/viewvc/llvm-project?rev=203140&view=rev
Log:
Fix use-after-free detected by ASan bootstrap.
Modified:
cfe/trunk/lib/Lex/HeaderSearch.cpp
Modified: cfe/trunk/lib/Lex/HeaderSearch.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/HeaderSearch.cpp?rev=203140&r1=203139&r2=203140&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/HeaderSearch.cpp (original)
+++ cfe/trunk/lib/Lex/HeaderSearch.cpp Thu Mar 6 12:08:08 2014
@@ -603,10 +603,14 @@ const FileEntry *HeaderSearch::LookupFil
TmpDir.push_back('/');
TmpDir.append(Filename.begin(), Filename.end());
- HeaderFileInfo &FromHFI = getFileInfo(Includer);
+ // FIXME: We don't cache the result of getFileInfo across the call to
+ // getFileAndSuggestModule, because it's a reference to an element of
+ // a container that could be reallocated across this call.
+ bool IncluderIsSystemHeader =
+ getFileInfo(Includer).DirInfo != SrcMgr::C_User;
if (const FileEntry *FE =
getFileAndSuggestModule(*this, TmpDir.str(), Includer->getDir(),
- FromHFI.DirInfo != SrcMgr::C_User,
+ IncluderIsSystemHeader,
SuggestedModule)) {
// Leave CurDir unset.
// This file is a system header or C++ unfriendly if the old file is.
@@ -614,6 +618,7 @@ const FileEntry *HeaderSearch::LookupFil
// Note that we only use one of FromHFI/ToHFI at once, due to potential
// reallocation of the underlying vector potentially making the first
// reference binding dangling.
+ HeaderFileInfo &FromHFI = getFileInfo(Includer);
unsigned DirInfo = FromHFI.DirInfo;
bool IndexHeaderMapHeader = FromHFI.IndexHeaderMapHeader;
StringRef Framework = FromHFI.Framework;
More information about the cfe-commits
mailing list