mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-12 23:01:16 -03:00
Fix for infinite loop in cycle_competions, and potential issue in
fish_pager when given an empty completion list
This commit is contained in:
@@ -1702,18 +1702,17 @@ static const completion_t *cycle_competions(const std::vector<completion_t> &com
|
||||
if (size == 0)
|
||||
return NULL;
|
||||
|
||||
// note start_idx will be set to -1 initially, so that when it gets incremented we start at 0
|
||||
const size_t start_idx = *inout_idx;
|
||||
size_t idx = start_idx;
|
||||
|
||||
const completion_t *result = NULL;
|
||||
for (;;)
|
||||
size_t remaining = comp.size();
|
||||
while (remaining--)
|
||||
{
|
||||
/* Bump the index */
|
||||
idx = (idx + 1) % size;
|
||||
|
||||
/* Bail if we've looped */
|
||||
if (idx == start_idx)
|
||||
break;
|
||||
|
||||
/* Get the completion */
|
||||
const completion_t &c = comp.at(idx);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user