[Lldb-commits] [lldb] r335960 - Fix use-after-free in CommandCompletions.cpp

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Fri Jun 29 03:27:18 PDT 2018


Author: labath
Date: Fri Jun 29 03:27:18 2018
New Revision: 335960

URL: http://llvm.org/viewvc/llvm-project?rev=335960&view=rev
Log:
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.

Modified:
    lldb/trunk/source/Commands/CommandCompletions.cpp

Modified: lldb/trunk/source/Commands/CommandCompletions.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandCompletions.cpp?rev=335960&r1=335959&r2=335960&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandCompletions.cpp (original)
+++ lldb/trunk/source/Commands/CommandCompletions.cpp Fri Jun 29 03:27:18 2018
@@ -164,7 +164,7 @@ static int DiskFilesOrDirectories(const
     // 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());




More information about the lldb-commits mailing list