From 735283a799dc6583eb0a94adf3588773a4f04557 Mon Sep 17 00:00:00 2001 From: Jack Palevich Date: Sun, 27 Jul 2014 17:09:48 +0800 Subject: [PATCH] Avoid crash if p.have.n is 0 Work around issue #54. --- torrent/torrent.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/torrent/torrent.go b/torrent/torrent.go index e70ff43..d93a6d5 100644 --- a/torrent/torrent.go +++ b/torrent/torrent.go @@ -815,7 +815,7 @@ func (t *TorrentSession) RecordBlock(p *peerState, piece, begin, length uint32) } for _, p := range t.peers { if p.have != nil { - if p.have.IsSet(int(piece)) { + if int(piece) < p.have.n && p.have.IsSet(int(piece)) { // We don't do anything special. We rely on the caller // to decide if this peer is still interesting. } else {