From c5234b8605c0329add77fe5aaf3337288c4a57d8 Mon Sep 17 00:00:00 2001 From: Masaaki Goshima Date: Sat, 6 Feb 2021 21:42:19 +0900 Subject: [PATCH] Fix streaming decoder --- decode_struct.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/decode_struct.go b/decode_struct.go index 6bb45c2..2a3d1db 100644 --- a/decode_struct.go +++ b/decode_struct.go @@ -331,6 +331,11 @@ func decodeKeyByBitmapInt8Stream(d *structDecoder, s *stream) (*structFieldSet, switch s.char() { case ' ', '\n', '\t', '\r': s.cursor++ + case nul: + if s.read() { + continue + } + return nil, "", errNotAtBeginningOfValue(s.totalOffset()) case '"': s.cursor++ FIRST_CHAR: @@ -434,6 +439,11 @@ func decodeKeyByBitmapInt16Stream(d *structDecoder, s *stream) (*structFieldSet, switch s.char() { case ' ', '\n', '\t', '\r': s.cursor++ + case nul: + if s.read() { + continue + } + return nil, "", errNotAtBeginningOfValue(s.totalOffset()) case '"': s.cursor++ FIRST_CHAR: @@ -585,9 +595,6 @@ func (d *structDecoder) decodeStream(s *stream, p unsafe.Pointer) error { } } s.skipWhiteSpace() - if s.char() == nul { - s.read() - } c := s.char() if c == '}' { s.cursor++