]> granicus.if.org Git - clang/commitdiff
Fix use-after-destruction introduced in r224924.
authorAlexey Samsonov <vonosmas@gmail.com>
Mon, 29 Dec 2014 21:28:15 +0000 (21:28 +0000)
committerAlexey Samsonov <vonosmas@gmail.com>
Mon, 29 Dec 2014 21:28:15 +0000 (21:28 +0000)
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

lib/Frontend/CompilerInvocation.cpp

index 1fdfc8de687096e918fc4d17cd2a9eee13b1c0cb..5b3442841399c95cb659c59d2c4e9dc8a878d596 100644 (file)
@@ -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.