Skip to content

Commit 0544a43

Browse files
authored
Merge pull request #16085 from karalabe/p2p-fix-outofbounds
p2p/discover: fix out-of-bounds issue
2 parents 88f2839 + 2079734 commit 0544a43

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

p2p/discover/table.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -763,7 +763,7 @@ func (tab *Table) addReplacement(b *bucket, n *Node) {
763763
// last entry in the bucket. If 'last' isn't the last entry, it has either been replaced
764764
// with someone else or became active.
765765
func (tab *Table) replace(b *bucket, last *Node) *Node {
766-
if len(b.entries) >= 0 && b.entries[len(b.entries)-1].ID != last.ID {
766+
if len(b.entries) == 0 || b.entries[len(b.entries)-1].ID != last.ID {
767767
// Entry has moved, don't replace it.
768768
return nil
769769
}

0 commit comments

Comments
 (0)