Skip to content

Commit 4b5a8d6

Browse files
authored
[lldb] Make sure completions don't end with newlines (llvm#117054)
The logic that prints completions and their descriptions assumes neither the completion itself nor the description ends with a newline. I considered making this an assert, but decided against it as completions can indirectly come from user input (e.g. oddly crafted names). Instead, avoid the potential for mistakes by defensively stripping them.
1 parent 5889f68 commit 4b5a8d6

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lldb/include/lldb/Utility/CompletionRequest.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ class CompletionResult {
5252
public:
5353
Completion(llvm::StringRef completion, llvm::StringRef description,
5454
CompletionMode mode)
55-
: m_completion(completion.str()), m_descripton(description.str()),
56-
m_mode(mode) {}
55+
: m_completion(completion.rtrim().str()),
56+
m_descripton(description.rtrim().str()), m_mode(mode) {}
5757
const std::string &GetCompletion() const { return m_completion; }
5858
const std::string &GetDescription() const { return m_descripton; }
5959
CompletionMode GetMode() const { return m_mode; }

0 commit comments

Comments
 (0)