r201209 - Fix r201205's use-after-free bug caught by sanitizer bot
Jonathan Roelofs
jonathan at codesourcery.com
Tue Feb 11 22:37:27 PST 2014
Author: jroelofs
Date: Wed Feb 12 00:37:27 2014
New Revision: 201209
URL: http://llvm.org/viewvc/llvm-project?rev=201209&view=rev
Log:
Fix r201205's use-after-free bug caught by sanitizer bot
Modified:
cfe/trunk/lib/Driver/Multilib.cpp
Modified: cfe/trunk/lib/Driver/Multilib.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Multilib.cpp?rev=201209&r1=201208&r2=201209&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Multilib.cpp (original)
+++ cfe/trunk/lib/Driver/Multilib.cpp Wed Feb 12 00:37:27 2014
@@ -31,16 +31,14 @@ using namespace clang;
using namespace llvm::opt;
static void normalizePathSegment(std::string &Segment) {
- StringRef SRS(Segment);
- if (SRS.empty() || SRS == "/." || SRS == "/" || SRS == ".") {
- SRS = "";
+ if (Segment.empty() || Segment == "/." || Segment == "/" || Segment == ".") {
+ Segment = "";
} else {
- if (SRS.back() == '/')
- SRS = SRS.drop_back();
- if (SRS.front() != '/')
- SRS = ("/" + SRS).str();
+ if (StringRef(Segment).back() == '/')
+ Segment.erase(Segment.begin() + Segment.size() - 1);
+ if (StringRef(Segment).front() != '/')
+ Segment = "/" + Segment;
}
- Segment = SRS;
}
Multilib::Multilib(StringRef GCCSuffix, StringRef OSSuffix,
More information about the cfe-commits
mailing list