]> Cypherpunks.ru repositories - gostls13.git/commitdiff
bufio: mention that panic at slicing means underlying reader is broken
authorKeith Randall <khr@golang.org>
Fri, 26 Nov 2021 15:36:09 +0000 (07:36 -0800)
committerKeith Randall <khr@golang.org>
Fri, 26 Nov 2021 22:36:21 +0000 (22:36 +0000)
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>
src/bufio/bufio.go

index 9ea058db3eddd54dae5d0ccecd71120f58ae05b4..7483946fc0aabf3e0dffaa07608369c1f473a0f3 100644 (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])