Skip to content

Commit 8d6f3b8

Browse files
committed
Reset internal buffer when rows.Close() is called.
Fixes #903
1 parent 60d456a commit 8d6f3b8

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

buffer.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ func newBuffer(nc net.Conn) buffer {
3737
}
3838
}
3939

40+
func (b *buffer) reset() {
41+
b.buf = make([]byte, defaultBufSize)
42+
}
43+
4044
// fill reads into the buffer until at least _need_ bytes are in it
4145
func (b *buffer) fill(need int) error {
4246
n := b.length

rows.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,10 @@ func (rows *mysqlRows) Close() (err error) {
111111
return err
112112
}
113113

114+
// We can't reuse receive buffer when rows.Close() is called.
115+
// See https://github.com/golang/go/commit/651ddbdb5056ded455f47f9c494c67b389622a47
116+
mc.buf.reset()
117+
114118
// Remove unread packets from stream
115119
if !rows.rs.done {
116120
err = mc.readUntilEOF()

0 commit comments

Comments
 (0)