Skip to content

Commit

Permalink
Merge pull request #16085 from karalabe/p2p-fix-outofbounds
Browse files Browse the repository at this point in the history
p2p/discover: fix out-of-bounds issue
  • Loading branch information
karalabe authored Feb 13, 2018
2 parents 88f2839 + 2079734 commit 0544a43
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion p2p/discover/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,7 @@ func (tab *Table) addReplacement(b *bucket, n *Node) {
// last entry in the bucket. If 'last' isn't the last entry, it has either been replaced
// with someone else or became active.
func (tab *Table) replace(b *bucket, last *Node) *Node {
if len(b.entries) >= 0 && b.entries[len(b.entries)-1].ID != last.ID {
if len(b.entries) == 0 || b.entries[len(b.entries)-1].ID != last.ID {
// Entry has moved, don't replace it.
return nil
}
Expand Down

0 comments on commit 0544a43

Please sign in to comment.