1
0
mirror of https://github.com/golang/go synced 2024-11-17 12:04:43 -07:00

bufio: mention that panic at slicing means underlying reader is broken

Fixes #49795

Change-Id: I2b4fd14f0ed36b643522559bebf5ce52b1d7b304
Reviewed-on: https://go-review.googlesource.com/c/go/+/367214
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
Keith Randall 2021-11-26 07:36:09 -08:00
parent bf88adadac
commit 1d47a1184a

View File

@ -244,6 +244,8 @@ func (b *Reader) Read(p []byte) (n int, err error) {
}
// copy as much as we can
// Note: if the slice panics here, it is probably because
// the underlying reader returned a bad count. See issue 49795.
n = copy(p, b.buf[b.r:b.w])
b.r += n
b.lastByte = int(b.buf[b.r-1])