diff options
author | ridiculousfish <corydoras@ridiculousfish.com> | 2013-09-10 21:13:47 -0700 |
---|---|---|
committer | ridiculousfish <corydoras@ridiculousfish.com> | 2013-09-10 21:13:47 -0700 |
commit | 61c5b631f3d0050984c938e63525fe8e22fabff2 (patch) | |
tree | 49243793199c5a0f7f0265345204287b517f3997 /reader.cpp | |
parent | b993dce12ff3e5b8e38c761706c9db1ef101aee4 (diff) |
Fix for infinite loop in cycle_competions, and potential issue in
fish_pager when given an empty completion list
Diffstat (limited to 'reader.cpp')
-rw-r--r-- | reader.cpp | 9 |
1 files changed, 4 insertions, 5 deletions
@@ -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); |