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 | a60a522fced577e26041a4885acba6b71a435c91 (patch) | |
tree | 5506ee3b65621932f0189f45310f56465ad48627 /lib/Driver/Multilib.cpp | |
parent | ddccd4eca1d469a4efe5968f74a3ca20a953f5f4 (diff) |
Fix r201205's use-after-free bug caught by sanitizer bot
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@201209 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Driver/Multilib.cpp')
-rw-r--r-- | lib/Driver/Multilib.cpp | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/lib/Driver/Multilib.cpp b/lib/Driver/Multilib.cpp index 6d68517e83..746d01bfb2 100644 --- a/lib/Driver/Multilib.cpp +++ b/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, |