From 75767f5cb5189e72225e6a84cd578aed328bcb90 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Wed, 25 Oct 2017 11:26:03 +0800 Subject: [PATCH] Fix infinite loop shell_complete Fixes #1648 --- src/completion.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/completion.cc b/src/completion.cc index e85d5fe1..e5a664b0 100644 --- a/src/completion.cc +++ b/src/completion.cc @@ -14,7 +14,7 @@ Completions shell_complete(const Context& context, CompletionFlags flags, bool command = true; const ByteCount len = prefix.length(); - for (ByteCount pos = 0; pos < cursor_pos;) + for (ByteCount pos = 0; pos < cursor_pos and pos < len;) { command = (pos == 0 or prefix[pos-1] == ';' or prefix[pos-1] == '|' or (pos > 1 and prefix[pos-1] == '&' and prefix[pos-2] == '&'));