From: Matt Joiner Date: Mon, 30 Jun 2014 14:06:58 +0000 (+1000) Subject: Fix crash when peer has only sent lower-index HAVE messages X-Git-Tag: v1.0.0~1688 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=17acbb485caae6dafd26d724996830a436914463;p=btrtrc.git Fix crash when peer has only sent lower-index HAVE messages --- 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] }