aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2018-02-14 05:40:18 +0800
committerGitHub <noreply@github.com>2018-02-14 05:40:18 +0800
commit0544a43c1332871405b260432db4bfe6a591feee (patch)
tree5d0cf3714c930223eca67021975417562027c5de
parent88f2839da4993ab51c32fef8383136f3addaeb24 (diff)
parent20797348ca9d037dc5b7a830bafdfe1ea703eac0 (diff)
downloaddexon-0544a43c1332871405b260432db4bfe6a591feee.tar.gz
dexon-0544a43c1332871405b260432db4bfe6a591feee.tar.zst
dexon-0544a43c1332871405b260432db4bfe6a591feee.zip
Merge pull request #16085 from karalabe/p2p-fix-outofbounds
p2p/discover: fix out-of-bounds issue
-rw-r--r--p2p/discover/table.go2
1 files changed, 1 insertions, 1 deletions
diff --git a/p2p/discover/table.go b/p2p/discover/table.go
index 84c54dac1..17c9db777 100644
--- a/p2p/discover/table.go
+++ b/p2p/discover/table.go
@@ -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
}