From f67cad326a4cb0f71513a2a2fea4eb64baa837ce Mon Sep 17 00:00:00 2001 From: Bananymous Date: Mon, 7 Oct 2024 14:26:07 +0300 Subject: [PATCH] Shell: Don't crash when there are no tab completions available :D --- userspace/programs/Shell/main.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/userspace/programs/Shell/main.cpp b/userspace/programs/Shell/main.cpp index 1c679c6ef4..034c1ba4c6 100644 --- a/userspace/programs/Shell/main.cpp +++ b/userspace/programs/Shell/main.cpp @@ -1509,12 +1509,12 @@ int main(int argc, char** argv) } ); - for (size_t i = 0; i < completions.size() - 1; i++) + for (size_t i = 1; i < completions.size();) { - if (completions[i] != completions[i + 1]) - continue; - completions.remove(i + 1); - i--; + if (completions[i - 1] == completions[i]) + completions.remove(i); + else + i++; } if (completions.empty())