[Lldb-commits] [lldb] r226544 - Fix creation of StringRef in FileSpec::ResolveUsername()

Jason Molenda jmolenda at apple.com
Mon Jan 19 20:20:43 PST 2015


Author: jmolenda
Date: Mon Jan 19 22:20:42 2015
New Revision: 226544

URL: http://llvm.org/viewvc/llvm-project?rev=226544&view=rev
Log:
Fix creation of StringRef in FileSpec::ResolveUsername()
so it doesn't assume that the SmallVector<char> will have
nul terminator.  It did not in at least one case.
Caught by ASAN instrumentation.

Modified:
    lldb/trunk/source/Host/common/FileSpec.cpp

Modified: lldb/trunk/source/Host/common/FileSpec.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/FileSpec.cpp?rev=226544&r1=226543&r2=226544&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/FileSpec.cpp (original)
+++ lldb/trunk/source/Host/common/FileSpec.cpp Mon Jan 19 22:20:42 2015
@@ -65,7 +65,7 @@ FileSpec::ResolveUsername (llvm::SmallVe
     if (path.empty() || path[0] != '~')
         return;
     
-    llvm::StringRef path_str(path.data());
+    llvm::StringRef path_str(path.data(), path.size());
     size_t slash_pos = path_str.find_first_of("/", 1);
     if (slash_pos == 1 || path.size() == 1)
     {





More information about the lldb-commits mailing list