From de9695a7246a89aa6281752216f935be7b6eb3b3 Mon Sep 17 00:00:00 2001 From: Pavel Merzlyakov Date: Thu, 27 Jul 2023 01:51:27 +0300 Subject: [PATCH] reading mask without preceding nil value --- msgpack_reader.go | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/msgpack_reader.go b/msgpack_reader.go index f76a354..a9a0df5 100644 --- a/msgpack_reader.go +++ b/msgpack_reader.go @@ -530,25 +530,15 @@ func (rd *msgpackReader) Skip() error { } func (rd *msgpackReader) TryReadMask() (bool, FieldsMask, error) { - code, err := rd.dec.PeekCode() + maskLen, err := rd.dec.DecodeArrayLen() if err != nil { - return false, FieldsMask{}, errors.WithStack(err) - } - - if code != msgpcode.Nil { - return false, FieldsMask{}, nil - } - - if err := rd.dec.Skip(); err != nil { + if err == io.EOF { + return false, FieldsMask{}, nil + } return false, FieldsMask{}, errors.WithStack(err) } var mask FieldsMask - maskLen, err := rd.dec.DecodeArrayLen() - if err != nil { - return false, FieldsMask{}, errors.WithStack(err) - } - for i := 0; i < maskLen; i++ { maskPart, err := rd.dec.DecodeUint64() if err != nil {