]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Fix crash when peer has only sent lower-index HAVE messages
authorMatt Joiner <anacrolix@gmail.com>
Mon, 30 Jun 2014 14:06:58 +0000 (00:06 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Mon, 30 Jun 2014 14:06:58 +0000 (00:06 +1000)
connection.go

index f986c5cbcd01643948b95b0771ddd1d14994d376..91d5b327451cd8938165bdb0e7633f0edb8e829b 100644 (file)
@@ -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]
 }