Skip to content
This repository has been archived by the owner on Feb 1, 2023. It is now read-only.

Commit

Permalink
Merge pull request #144 from ipfs/fix/zero-rand
Browse files Browse the repository at this point in the history
fix: rand.Intn(0) panics
  • Loading branch information
Stebalien committed Jul 4, 2019
1 parent 4035bcd commit 258a8e9
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions session/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,9 @@ func (s *Session) handlePeriodicSearch(ctx context.Context) {
}

func (s *Session) randomLiveWant() cid.Cid {
if len(s.liveWants) == 0 {
return cid.Cid{}
}
i := rand.Intn(len(s.liveWants))
// picking a random live want
for k := range s.liveWants {
Expand Down

0 comments on commit 258a8e9

Please sign in to comment.