[cfe-commits] r108659 - in /cfe/trunk: include/clang/Driver/Driver.h lib/Driver/Tools.cpp

Daniel Dunbar daniel at zuster.org
Sun Jul 18 14:16:15 PDT 2010


Author: ddunbar
Date: Sun Jul 18 16:16:15 2010
New Revision: 108659

URL: http://llvm.org/viewvc/llvm-project?rev=108659&view=rev
Log:
Driver: Fix a possible use after free.

Modified:
    cfe/trunk/include/clang/Driver/Driver.h
    cfe/trunk/lib/Driver/Tools.cpp

Modified: cfe/trunk/include/clang/Driver/Driver.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Driver.h?rev=108659&r1=108658&r2=108659&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/Driver.h (original)
+++ cfe/trunk/include/clang/Driver/Driver.h Sun Jul 18 16:16:15 2010
@@ -167,8 +167,8 @@
   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();
   }
 
   /// @}

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=108659&r1=108658&r2=108659&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Sun Jul 18 16:16:15 2010
@@ -1489,7 +1489,7 @@
 
   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 @@
     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 @@
     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,





More information about the cfe-commits mailing list