diff options
author | Jonathan Roelofs <jonathan@codesourcery.com> | 2014-02-12 06:37:27 +0000 |
---|---|---|
committer | Jonathan Roelofs <jonathan@codesourcery.com> | 2014-02-12 06:37:27 +0000 |
commit | 4c991ef3ef77b775dc6e234d2fa1d2956fd0f694 (patch) | |
tree | ff2dfa47485814bafde8d781aecf41d15cebf3e8 /clang/lib/Driver/Multilib.cpp | |
parent | c5f7e6fe6779131fb9f8d15443ec6b3e5863117c (diff) | |
download | bcm5719-llvm-4c991ef3ef77b775dc6e234d2fa1d2956fd0f694.tar.gz bcm5719-llvm-4c991ef3ef77b775dc6e234d2fa1d2956fd0f694.zip |
Fix r201205's use-after-free bug caught by sanitizer bot
llvm-svn: 201209
Diffstat (limited to 'clang/lib/Driver/Multilib.cpp')
-rw-r--r-- | clang/lib/Driver/Multilib.cpp | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/clang/lib/Driver/Multilib.cpp b/clang/lib/Driver/Multilib.cpp index 6d68517e83f..746d01bfb24 100644 --- a/clang/lib/Driver/Multilib.cpp +++ b/clang/lib/Driver/Multilib.cpp @@ -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, |