Fix creation of StringRef in FileSpec::ResolveUsername()
authorJason Molenda <jmolenda@apple.com>
Tue, 20 Jan 2015 04:20:42 +0000 (04:20 +0000)
committerJason Molenda <jmolenda@apple.com>
Tue, 20 Jan 2015 04:20:42 +0000 (04:20 +0000)
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.

llvm-svn: 226544

lldb/source/Host/common/FileSpec.cpp

index 0af0556d30c9fcf71c2bf142f636da66681ec70d..98b4beffe286775a8f967f121aac0f3315e10dc7 100644 (file)
@@ -65,7 +65,7 @@ FileSpec::ResolveUsername (llvm::SmallVectorImpl<char> &path)
     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)
     {