aboutsummaryrefslogtreecommitdiff
path: root/src/database/sql/sql.go
diff options
context:
space:
mode:
authorDaniel Theophanes <kardianos@gmail.com>2018-03-25 16:58:27 -0700
committerDaniel Theophanes <kardianos@gmail.com>2018-05-10 19:41:08 +0000
commitb98ffdf859f0fec2acb1765bf5b62ce1e4587c2b (patch)
treeab292c776d26aff4698d727d4ec1c0267b4cebc7 /src/database/sql/sql.go
parentb9c8e870d14775a02c6e87ca0344f623f7cab5f0 (diff)
downloadgo-b98ffdf859f0fec2acb1765bf5b62ce1e4587c2b.tar.xz
database/sql: check for nil connRequest.conn before use
The connRequest may return a nil conn value. However in a rare case that is difficult to test for it was being passed to DB.putConn without a nil check. This was an error as this made no sense if the driverConn is nil. This also caused a panic in putConn. A test for this would be nice, but didn't find a sane way to test for this condition. Fixes #24445 Change-Id: I827316e856788a5a3ced913f129bb5869b7bcf68 Reviewed-on: https://go-review.googlesource.com/102477 Run-TryBot: Daniel Theophanes <kardianos@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Alexey Palazhchenko <alexey.palazhchenko@gmail.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'src/database/sql/sql.go')
-rw-r--r--src/database/sql/sql.go2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/database/sql/sql.go b/src/database/sql/sql.go
index ec7b526150..142ec027d8 100644
--- a/src/database/sql/sql.go
+++ b/src/database/sql/sql.go
@@ -1098,7 +1098,7 @@ func (db *DB) conn(ctx context.Context, strategy connReuseStrategy) (*driverConn
select {
default:
case ret, ok := <-req:
- if ok {
+ if ok && ret.conn != nil {
db.putConn(ret.conn, ret.err, false)
}
}