From 20797348ca9d037dc5b7a830bafdfe1ea703eac0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= Date: Tue, 13 Feb 2018 20:59:43 +0200 Subject: [PATCH] p2p/discover: fix out-of-bounds issue --- p2p/discover/table.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/p2p/discover/table.go b/p2p/discover/table.go index 84c54dac12..17c9db7774 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 }