From: Keith Randall Date: Fri, 26 Nov 2021 15:36:09 +0000 (-0800) Subject: bufio: mention that panic at slicing means underlying reader is broken X-Git-Tag: go1.18beta1~170 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=1d47a1184a4718a34ab1df4d9bf05a284aba4c70;p=gostls13.git 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 Run-TryBot: Keith Randall TryBot-Result: Go Bot Reviewed-by: Ian Lance Taylor --- diff --git a/src/bufio/bufio.go b/src/bufio/bufio.go index 9ea058db3e..7483946fc0 100644 --- a/src/bufio/bufio.go +++ b/src/bufio/bufio.go @@ -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])