]> granicus.if.org Git - clang/commitdiff
Driver: Fix a possible use after free.
authorDaniel Dunbar <daniel@zuster.org>
Sun, 18 Jul 2010 21:16:15 +0000 (21:16 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Sun, 18 Jul 2010 21:16:15 +0000 (21:16 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@108659 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Driver/Driver.h
lib/Driver/Tools.cpp

index bb578b516ce33c0a77bb95e3c2af54dfd482cb7e..89bc7436a8aed9c26eae9b280921c41dabe335d1 100644 (file)
@@ -167,8 +167,8 @@ public:
   void setTitle(std::string Value) { DriverTitle = Value; }
 
   /// \brief Get the path to the main clang executable.
-  std::string getClangProgramPath() const {
-    return ClangExecutable;
+  const char *getClangProgramPath() const {
+    return ClangExecutable.c_str();
   }
 
   /// @}
index f423d4e3b918699e85890f9f9957faa02596e763..6e6dab1088c3409248239b0755b20e39dc3d57c0 100644 (file)
@@ -1489,7 +1489,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
 
   Args.AddAllArgs(CmdArgs, options::OPT_undef);
 
-  std::string Exec = getToolChain().getDriver().getClangProgramPath();
+  const char *Exec = getToolChain().getDriver().getClangProgramPath();
 
   // Optionally embed the -cc1 level arguments into the debug info, for build
   // analysis.
@@ -1509,7 +1509,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
     CmdArgs.push_back(Args.MakeArgString(Flags.str()));
   }
 
-  Dest.addCommand(new Command(JA, *this, Exec.c_str(), CmdArgs));
+  Dest.addCommand(new Command(JA, *this, Exec, CmdArgs));
 
   // Explicitly warn that these options are unsupported, even though
   // we are allowing compilation to continue.
@@ -1588,8 +1588,8 @@ void ClangAs::ConstructJob(Compilation &C, const JobAction &JA,
     CmdArgs.push_back(Input.getFilename());
   }
 
-  std::string Exec = getToolChain().getDriver().getClangProgramPath();
-  Dest.addCommand(new Command(JA, *this, Exec.c_str(), CmdArgs));
+  const char *Exec = getToolChain().getDriver().getClangProgramPath();
+  Dest.addCommand(new Command(JA, *this, Exec, CmdArgs));
 }
 
 void gcc::Common::ConstructJob(Compilation &C, const JobAction &JA,