mirror of
https://github.com/fish-shell/fish-shell
synced 2024-11-10 07:04:29 +00: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:
parent
b993dce12f
commit
61c5b631f3
2 changed files with 9 additions and 5 deletions
|
@ -1370,6 +1370,11 @@ int main(int argc, char **argv)
|
|||
|
||||
// debug( 3, L"prefix is '%ls'", prefix );
|
||||
|
||||
if (comp.empty())
|
||||
{
|
||||
exit_without_destructors(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
init(mangle_descriptors, result_fd);
|
||||
|
||||
mangle_descriptions(comp);
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue