From: Alexey Samsonov Date: Mon, 29 Dec 2014 21:28:15 +0000 (+0000) Subject: Fix use-after-destruction introduced in r224924. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=dfa25cb2d16f812bb28bdf60b6b891f4e9140072;p=clang Fix use-after-destruction introduced in r224924. getMainExecutable() returns a std::string, assigning its result to StringRef immediately creates a dangling pointer. This was detected by half-broken fast-MSan-bootstrap bot. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@224956 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp index 1fdfc8de68..5b34428413 100644 --- a/lib/Frontend/CompilerInvocation.cpp +++ b/lib/Frontend/CompilerInvocation.cpp @@ -983,7 +983,8 @@ static InputKind ParseFrontendArgs(FrontendOptions &Opts, ArgList &Args, std::string CompilerInvocation::GetResourcesPath(const char *Argv0, void *MainAddr) { - StringRef ClangExecutable = llvm::sys::fs::getMainExecutable(Argv0, MainAddr); + std::string ClangExecutable = + llvm::sys::fs::getMainExecutable(Argv0, MainAddr); StringRef Dir = llvm::sys::path::parent_path(ClangExecutable); // Compute the path to the resource directory.