Driver: Fix a possible use after free.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@108659 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp
index f423d4e..6e6dab1 100644
--- a/lib/Driver/Tools.cpp
+++ b/lib/Driver/Tools.cpp
@@ -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,