Fix use-after-free in CommandCompletions.cpp

The code was creating a StringRef to a temporary std::string. The
solution is to just drop the .str() from the original StringRef.

This manifested it self as the new TestCompletions test failing in some
configurations.

llvm-svn: 335960
This commit is contained in:
Pavel Labath
2018-06-29 10:27:18 +00:00
parent 1f6ad14661
commit 88ec2e4ee7

View File

@@ -164,7 +164,7 @@ static int DiskFilesOrDirectories(const llvm::Twine &partial_name,
// search in the fully resolved directory, but CompletionBuffer keeps the
// unmodified form that the user typed.
Storage = Resolved;
llvm::StringRef RemainderDir = path::parent_path(Remainder.str());
llvm::StringRef RemainderDir = path::parent_path(Remainder);
if (!RemainderDir.empty()) {
// Append the remaining path to the resolved directory.
Storage.append(path::get_separator());