summaryrefslogtreecommitdiffstats
path: root/clang/lib/Driver/Driver.cpp
diff options
context:
space:
mode:
authorChad Rosier <mcrosier@apple.com>2011-08-26 21:47:20 +0000
committerChad Rosier <mcrosier@apple.com>2011-08-26 21:47:20 +0000
commitf0be551d68267d52b9ca7e852754da6a683eb7c1 (patch)
tree799bfee4acbc374e3b46b622a8a005ec66f7d716 /clang/lib/Driver/Driver.cpp
parent3d1eac85c39200526a5ceab429f8f9641f86607d (diff)
downloadbcm5719-llvm-f0be551d68267d52b9ca7e852754da6a683eb7c1.tar.gz
bcm5719-llvm-f0be551d68267d52b9ca7e852754da6a683eb7c1.zip
Make sure the std::string isn't deallocated prior to use. Many thanks to Eli
for catching this. llvm-svn: 138666
Diffstat (limited to 'clang/lib/Driver/Driver.cpp')
-rw-r--r--clang/lib/Driver/Driver.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index acdfdc21a25..66d2df16e11 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -1336,12 +1336,12 @@ void Driver::BuildJobsForAction(Compilation &C,
}
// Strip the directory and suffix from BaseInput.
-static const char *getBaseName (const char *BaseInput) {
+static std::string getBaseName (const char *BaseInput) {
std::pair<StringRef, StringRef> Split = StringRef(BaseInput).rsplit('/');
if (Split.second != "")
- return Split.second.split('.').first.str().c_str();
+ return Split.second.split('.').first.str();
else
- return Split.first.split('.').first.str().c_str();
+ return Split.first.split('.').first.str();
}
const char *Driver::GetNamedOutputPath(Compilation &C,
@@ -1364,7 +1364,7 @@ const char *Driver::GetNamedOutputPath(Compilation &C,
if ((!AtTopLevel && !C.getArgs().hasArg(options::OPT_save_temps)) ||
CCGenDiagnostics) {
std::string TmpName =
- GetTemporaryPath(getBaseName(BaseInput),
+ GetTemporaryPath(getBaseName(BaseInput).c_str(),
types::getTypeTempSuffix(JA.getType()));
return C.addTempFile(C.getArgs().MakeArgString(TmpName.c_str()));
}
@@ -1400,7 +1400,7 @@ const char *Driver::GetNamedOutputPath(Compilation &C,
if (!AtTopLevel && C.getArgs().hasArg(options::OPT_save_temps) &&
NamedOutput == BaseName) {
std::string TmpName =
- GetTemporaryPath(getBaseName(BaseInput),
+ GetTemporaryPath(getBaseName(BaseInput).c_str(),
types::getTypeTempSuffix(JA.getType()));
return C.addTempFile(C.getArgs().MakeArgString(TmpName.c_str()));
}
OpenPOWER on IntegriCloud