]> Cypherpunks repositories - gostls13.git/commit
database/sql: ensure releaseConn is defined before a possible close
authorDaniel Theophanes <kardianos@gmail.com>
Fri, 28 Apr 2017 21:24:31 +0000 (14:24 -0700)
committerDaniel Theophanes <kardianos@gmail.com>
Fri, 28 Apr 2017 22:55:26 +0000 (22:55 +0000)
commit2133d63fa81777315981fbf961338218832e5099
tree0b080a9184ba215660db4a9ffa526dc8cf776279
parent295d160e017edce29b3dccfa7bb7a9e5d9434b26
database/sql: ensure releaseConn is defined before a possible close

When running a Query on Stmt a dependency is added to the stmt and
rows. To do that it needs a reference to Rows, so the releaseConn
function is defined after the definition. However the
rows.initContextClose was set to run before the releaseConn was
set on rows, setting up a situation where the connection could
be canceled before the releaseConn was set and resulting in
a segfault.

Fixes #20160

Change-Id: I5592e7db2cf653dfc48d42cbc2b03ca20501b1a0
Reviewed-on: https://go-review.googlesource.com/42139
Run-TryBot: Daniel Theophanes <kardianos@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/database/sql/sql.go
src/database/sql/sql_test.go