1
0
mirror of https://github.com/veggiedefender/torrent-client.git synced 2025-11-06 09:29:16 +02:00

Close connection after handling error

Fixes segfault when connection refused
This commit is contained in:
Jesse Li
2019-12-24 10:19:40 -05:00
parent cdfb02a591
commit aa8ef0ed76

View File

@@ -29,10 +29,10 @@ type Downloader struct {
// Download downloads a torrent
func (d *Downloader) Download() error {
conn, err := d.Peers[0].connect(d.PeerID, d.InfoHash)
defer conn.Close()
if err != nil {
return err
}
defer conn.Close()
h, err := d.handshake(conn)
if err != nil {
return err