From 81831733af68134c89c389f69affde4d6329e225 Mon Sep 17 00:00:00 2001 From: Mike Williamson Date: Mon, 19 Oct 2015 19:36:41 +0100 Subject: [PATCH] Fix potential race condition bug --- tds.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tds.go b/tds.go index 16718ee4..2087e713 100644 --- a/tds.go +++ b/tds.go @@ -824,7 +824,8 @@ func dialConnection(p *connectParams) (conn net.Conn, err error) { } } } - if err != nil { + // Can't do the usual err != nil check, as it is possible to have gotten an error before a successful connection + if conn == nil { f := "Unable to open tcp connection with host '%v:%v': %v" return nil, fmt.Errorf(f, p.host, p.port, err.Error()) }