From c880b916ee9866673a623e03ec743d6f81ad434b Mon Sep 17 00:00:00 2001 From: RPRX <63339210+rprx@users.noreply.github.com> Date: Wed, 27 Jan 2021 01:09:58 +0000 Subject: [PATCH] Avoid panic in BytesTo func --- common/buf/buffer.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/common/buf/buffer.go b/common/buf/buffer.go index a9745b8e..9b32c6c7 100644 --- a/common/buf/buffer.go +++ b/common/buf/buffer.go @@ -110,6 +110,9 @@ func (b *Buffer) BytesTo(to int32) []byte { if to < 0 { to += b.Len() } + if to < 0 { + to = 0 + } return b.v[b.start : b.start+to] }