diff --git a/src/common/hostlist.c b/src/common/hostlist.c index af897a9399283ff41db27f3995c134d6b9ec7976..0722be7785b8e303d3683d672411c5f955f4e10d 100644 --- a/src/common/hostlist.c +++ b/src/common/hostlist.c @@ -804,7 +804,7 @@ static int hostrange_width_combine(hostrange_t h0, hostrange_t h1) static int hostrange_empty(hostrange_t hr) { assert(hr != NULL); - return hr->hi < hr->lo; + return ((hr->hi < hr->lo) || (hr->hi == (unsigned long) -1)); } /* return the string representation of the last host in hostrange hr @@ -2214,9 +2214,11 @@ static void _iterator_advance(hostlist_iterator_t i) { assert(i != NULL); assert(i->magic == HOSTLIST_MAGIC); + if (i->idx > i->hl->nranges - 1) return; - if (++(i->depth) > i->hr->hi - i->hr->lo) { + + if (++(i->depth) > (i->hr->hi - i->hr->lo)) { i->depth = 0; i->hr = i->hl->hr[++i->idx]; } @@ -2300,12 +2302,12 @@ int hostlist_remove(hostlist_iterator_t i) if (new) { hostlist_insert_range(i->hl, new, i->idx + 1); hostrange_destroy(new); - i->hr = i->hl->hr[i->idx]; + i->hr = i->hl->hr[++i->idx]; i->depth = -1; } else if (hostrange_empty(i->hr)) { hostlist_delete_range(i->hl, i->idx); - i->hr = i->hl->hr[i->idx]; - i->depth = -1; + /* i->hr = i->hl->hr[i->idx]; + i->depth = -1; */ } else i->depth--;