From 2ff3cb3adc01768e0a552b3a02575a6df38a9bea Mon Sep 17 00:00:00 2001 From: Adrian Serrano Date: Tue, 7 May 2019 21:18:18 +0200 Subject: [PATCH] Fix connection leak on SSL failure When connecting to a server using SSL fails (i.e. with SSL disabled) the connection was never freed. Fixes #840 --- conn.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/conn.go b/conn.go index 786b8913..012c8c7c 100644 --- a/conn.go +++ b/conn.go @@ -301,6 +301,9 @@ func (c *Connector) open(ctx context.Context) (cn *conn, err error) { err = cn.ssl(o) if err != nil { + if cn.c != nil { + cn.c.Close() + } return nil, err }