Skip to content

Commit edd28f1

Browse files
kardianosbradfitz
authored andcommitted
[release-branch.go1.10] 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. Updates golang#24445 Fixes golang#25235 Change-Id: I827316e856788a5a3ced913f129bb5869b7bcf68 Reviewed-on: https://go-review.googlesource.com/102477 Run-TryBot: Daniel Theophanes <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Alexey Palazhchenko <[email protected]> Reviewed-by: Brad Fitzpatrick <[email protected]> (cherry picked from commit b98ffdf) Reviewed-on: https://go-review.googlesource.com/c/146778 Run-TryBot: Brad Fitzpatrick <[email protected]> Reviewed-by: Katie Hockman <[email protected]>
1 parent fba2c4d commit edd28f1

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/database/sql/sql.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1070,7 +1070,7 @@ func (db *DB) conn(ctx context.Context, strategy connReuseStrategy) (*driverConn
10701070
select {
10711071
default:
10721072
case ret, ok := <-req:
1073-
if ok {
1073+
if ok && ret.conn != nil {
10741074
db.putConn(ret.conn, ret.err, false)
10751075
}
10761076
}

0 commit comments

Comments
 (0)