connection.go | 3 +++ diff --git a/connection.go b/connection.go index f986c5cbcd01643948b95b0771ddd1d14994d376..91d5b327451cd8938165bdb0e7633f0edb8e829b 100644 --- a/connection.go +++ b/connection.go @@ -104,6 +104,9 @@ func (c *connection) PeerHasPiece(index peer_protocol.Integer) bool { if c.PeerPieces == nil { return false } + if int(index) >= len(c.PeerPieces) { + return false + } return c.PeerPieces[index] }