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 {