From a287d069a447cb7ac18eedcb3b213f70c24329da Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Tue, 12 Jun 2018 20:17:15 +1000 Subject: [PATCH] Fix crash adding peers when Torrent is closed --- torrent.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/torrent.go b/torrent.go index 99b71ae4..9b3ff31e 100644 --- a/torrent.go +++ b/torrent.go @@ -249,6 +249,9 @@ func (t *Torrent) unclosedConnsAsSlice() (ret []*connection) { func (t *Torrent) addPeer(p Peer) { cl := t.cl peersAddedBySource.Add(string(p.Source), 1) + if t.closed.IsSet() { + return + } if cl.badPeerIPPort(p.IP, p.Port) { torrent.Add("peers not added because of bad addr", 1) return -- 2.48.1