database/sql: buffers provided to Rows.Next should not be modified by drivers

Previously we allowed drivers to modify the row buffer used to scan
values when closing Rows. This is no longer acceptable and can lead
to data races.

Fixes #23519

Change-Id: I91820a6266ffe52f95f40bb47307d375727715af
Reviewed-on: https://go-review.googlesource.com/89936
Run-TryBot: Daniel Theophanes <kardianos@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
This commit is contained in:
Daniel Theophanes 2018-01-25 10:50:02 -08:00
parent 7350297eb6
commit 651ddbdb50
4 changed files with 14 additions and 42 deletions

View file

@ -1020,11 +1020,6 @@ func (rc *rowsCursor) touchMem() {
}
func (rc *rowsCursor) Close() error {
if !rc.closed {
for _, bs := range rc.bytesClone {
bs[0] = 255 // first byte corrupted
}
}
rc.touchMem()
rc.parentMem.touchMem()
rc.closed = true