[cfe-commits] r138666 - /cfe/trunk/lib/Driver/Driver.cpp
Chad Rosier
mcrosier at apple.com
Fri Aug 26 14:47:20 PDT 2011
Author: mcrosier
Date: Fri Aug 26 16:47:20 2011
New Revision: 138666
URL: http://llvm.org/viewvc/llvm-project?rev=138666&view=rev
Log:
Make sure the std::string isn't deallocated prior to use. Many thanks to Eli
for catching this.
Modified:
cfe/trunk/lib/Driver/Driver.cpp
Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=138666&r1=138665&r2=138666&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Fri Aug 26 16:47:20 2011
@@ -1336,12 +1336,12 @@
}
// 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 @@
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 @@
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()));
}
More information about the cfe-commits
mailing list