From a24dfdbabf58e93a83898850a0d53f111b340609 Mon Sep 17 00:00:00 2001 From: Aleksandr Razumov Date: Tue, 4 Jun 2019 18:44:32 +0300 Subject: [PATCH] Fix buffer grow for n < length Forbid buffer length decrease. --- message.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/message.go b/message.go index d9c1ef2..8fbe588 100644 --- a/message.go +++ b/message.go @@ -106,6 +106,9 @@ func (m *Message) Reset() { // grow ensures that internal buffer has n length. func (m *Message) grow(n int) { + if len(m.Raw) >= n { + return + } if cap(m.Raw) >= n { m.Raw = m.Raw[:n] return