wtclient: make addr iterator panic safe

Ensure that calling Next twice in a row without first calling Reset is
safe when the iterator is at the end of its list. Also alter the
towerListIterator to call Reset after hitting an error on Next.
This commit is contained in:
Elle Mouton
2023-03-30 11:49:58 +02:00
parent 1047514515
commit 9e4c8dd509
3 changed files with 6 additions and 7 deletions

View File

@@ -145,6 +145,7 @@ func (t *towerListIterator) AddCandidate(candidate *Tower) {
for {
next, err := candidate.Addresses.Next()
if err != nil {
candidate.Addresses.Reset()
break
}