From 1d47a1184a4718a34ab1df4d9bf05a284aba4c70 Mon Sep 17 00:00:00 2001 From: Keith Randall Date: Fri, 26 Nov 2021 07:36:09 -0800 Subject: [PATCH] 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 --- src/bufio/bufio.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/bufio/bufio.go b/src/bufio/bufio.go index 9ea058db3ed..7483946fc0a 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])