From: Matt Joiner Date: Wed, 10 Apr 2019 08:27:54 +0000 (+1000) Subject: Fix segfault on nil conntrack.EntryHandle instance when dialing X-Git-Tag: v1.1.3^0 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=bc249730aac7a6c89dd1bfb5a2f2436ddba496d3;p=btrtrc.git Fix segfault on nil conntrack.EntryHandle instance when dialing Fixes https://github.com/anacrolix/torrent/issues/314. Comments were added to the the conntrack package master, but have no functional change required here. --- diff --git a/client.go b/client.go index f8d70372..2d2a3fa7 100644 --- a/client.go +++ b/client.go @@ -521,8 +521,13 @@ func (cl *Client) dialFirst(ctx context.Context, addr string) dialResult { "dial torrent client", 0, ) + // Try to avoid committing to a dial if the context is complete as it's + // difficult to determine which dial errors allow us to forget the connection + // tracking entry handle. if ctx.Err() != nil { - cte.Forget() + if cte != nil { + cte.Forget() + } resCh <- dialResult{} return }