Skip to content

Commit

Permalink
Merge pull request #28 from DBCDK/fix-27
Browse files Browse the repository at this point in the history
Make sure the limit operator doesn't cause out-of-bounds errors
  • Loading branch information
johanot authored Nov 15, 2018
2 parents 0794c50 + 2d111df commit 16861df
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions filter/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ func FilterHosts(allHosts []nix.Host, skip int, every int, limit int) (hosts []n
}
}

// limit to $limit hosts
if limit > 0 {
// limit to $limit hosts, making sure not to go out of bounds either
if limit > 0 && limit < len(hosts) {
return hosts[:limit]
} else {
return hosts
Expand Down

0 comments on commit 16861df

Please sign in to comment.