From 17acbb485caae6dafd26d724996830a436914463 Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Tue, 1 Jul 2014 00:06:58 +1000 Subject: [PATCH] Fix crash when peer has only sent lower-index HAVE messages --- connection.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/connection.go b/connection.go index f986c5cb..91d5b327 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] } -- 2.48.1