Skip to content

Commit 8dcc86a

Browse files
author
walter erquinigo
committed
[LLDB] Fix completion of space-only lines in the REPL on Linux
modular/modular#1796 discovered that if you try to complete a space-only line in the REPL on Linux, LLDB crashes. I suspect that editline doesn't behave the same way on linux and on darwin, because I can't replicate this on darwin. Adding a boundary check in the completion code prevents the crash from happening.
1 parent 0d6ed83 commit 8dcc86a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lldb/source/Host/common/Editline.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1029,8 +1029,11 @@ unsigned char Editline::TabCommand(int ch) {
10291029
case CompletionMode::Normal: {
10301030
std::string to_add = completion.GetCompletion();
10311031
// Terminate the current argument with a quote if it started with a quote.
1032-
if (!request.GetParsedLine().empty() && request.GetParsedArg().IsQuoted())
1032+
Args &parsedLine = request.GetParsedLine();
1033+
if (!parsedLine.empty() && request.GetCursorIndex() < parsedLine.size() &&
1034+
request.GetParsedArg().IsQuoted()) {
10331035
to_add.push_back(request.GetParsedArg().GetQuoteChar());
1036+
}
10341037
to_add.push_back(' ');
10351038
el_deletestr(m_editline, request.GetCursorArgumentPrefix().size());
10361039
el_insertstr(m_editline, to_add.c_str());

0 commit comments

Comments
 (0)