aboutsummaryrefslogtreecommitdiffhomepage
path: root/reader.cpp
diff options
context:
space:
mode:
authorGravatar ridiculousfish <corydoras@ridiculousfish.com>2013-09-10 21:13:47 -0700
committerGravatar ridiculousfish <corydoras@ridiculousfish.com>2013-09-10 21:13:47 -0700
commit61c5b631f3d0050984c938e63525fe8e22fabff2 (patch)
tree49243793199c5a0f7f0265345204287b517f3997 /reader.cpp
parentb993dce12ff3e5b8e38c761706c9db1ef101aee4 (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.cpp9
1 files changed, 4 insertions, 5 deletions
diff --git a/reader.cpp b/reader.cpp
index c3630d73..a1074627 100644
--- a/reader.cpp
+++ b/reader.cpp
@@ -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);