diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2014-03-06 18:08:08 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2014-03-06 18:08:08 +0000 |
commit | 6f548ec37e670f9a46c7a3e937d10b60bf71f802 (patch) | |
tree | 098a5c2d88c3dd5eba241ee79863b0c0ec29bad5 /clang/lib/Lex/HeaderSearch.cpp | |
parent | 9b5256c56611cc947c50947f22d1fed68d641b20 (diff) | |
download | bcm5719-llvm-6f548ec37e670f9a46c7a3e937d10b60bf71f802.tar.gz bcm5719-llvm-6f548ec37e670f9a46c7a3e937d10b60bf71f802.zip |
Fix use-after-free detected by ASan bootstrap.
llvm-svn: 203140
Diffstat (limited to 'clang/lib/Lex/HeaderSearch.cpp')
-rw-r--r-- | clang/lib/Lex/HeaderSearch.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/clang/lib/Lex/HeaderSearch.cpp b/clang/lib/Lex/HeaderSearch.cpp index 11af5854a2e..3c5eb0ead8c 100644 --- a/clang/lib/Lex/HeaderSearch.cpp +++ b/clang/lib/Lex/HeaderSearch.cpp @@ -603,10 +603,14 @@ const FileEntry *HeaderSearch::LookupFile( 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::LookupFile( // 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; |