aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Commands/CommandObjectMultiword.cpp
diff options
context:
space:
mode:
authorJonas Devlieghere <jonas@devlieghere.com>2023-07-10 13:59:07 -0700
committerJonas Devlieghere <jonas@devlieghere.com>2023-07-10 14:50:40 -0700
commitfb10b01cca85306c8a94826e31e8a4dfb8aff502 (patch)
tree18ab5396b69a87dbb04cf7d9fa5c65f7284373f8 /lldb/source/Commands/CommandObjectMultiword.cpp
parent0e7ff05fb35169addd970f55b2692382ad290b78 (diff)
downloadllvm-fb10b01cca85306c8a94826e31e8a4dfb8aff502.zip
llvm-fb10b01cca85306c8a94826e31e8a4dfb8aff502.tar.gz
llvm-fb10b01cca85306c8a94826e31e8a4dfb8aff502.tar.bz2
[lldb] Prevent crash when completing ambiguous subcommands
Fix a crash when trying to complete an ambiguous subcommand. Take `set s tar` for example: for the subcommand `s` there's ambiguity between set and show. Pressing TAB after this input currently crashes LLDB. The problem is that we're trying to complete `tar` but give up at `s` because of the ambiguity. LLDB doesn't expect the completed string to be shorter than the current string and crashes when trying to eliminate the common prefix. rdar://111848598 Differential revision: https://reviews.llvm.org/D154643
Diffstat (limited to 'lldb/source/Commands/CommandObjectMultiword.cpp')
-rw-r--r--lldb/source/Commands/CommandObjectMultiword.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/lldb/source/Commands/CommandObjectMultiword.cpp b/lldb/source/Commands/CommandObjectMultiword.cpp
index bae2717..7ef829a 100644
--- a/lldb/source/Commands/CommandObjectMultiword.cpp
+++ b/lldb/source/Commands/CommandObjectMultiword.cpp
@@ -274,10 +274,10 @@ void CommandObjectMultiword::HandleCompletion(CompletionRequest &request) {
StringList new_matches;
CommandObject *sub_command_object = GetSubcommandObject(arg0, &new_matches);
- if (sub_command_object == nullptr) {
- request.AddCompletions(new_matches);
+
+ // The subcommand is ambiguous. The completion isn't meaningful.
+ if (!sub_command_object)
return;
- }
// Remove the one match that we got from calling GetSubcommandObject.
new_matches.DeleteStringAtIndex(0);