From 9a2f108208af8c1ba3d1cbe957c65d8cca2231d2 Mon Sep 17 00:00:00 2001 From: IncSW Date: Tue, 15 Jun 2021 19:05:12 +0300 Subject: [PATCH] fix array stream decoder --- internal/decoder/array.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/internal/decoder/array.go b/internal/decoder/array.go index 7caaf75..21f1fd5 100644 --- a/internal/decoder/array.go +++ b/internal/decoder/array.go @@ -46,8 +46,16 @@ func (d *arrayDecoder) DecodeStream(s *Stream, depth int64, p unsafe.Pointer) er return nil case '[': idx := 0 - for { + s.cursor++ + if s.skipWhiteSpace() == ']' { + for idx < d.alen { + *(*unsafe.Pointer)(unsafe.Pointer(uintptr(p) + uintptr(idx)*d.size)) = d.zeroValue + idx++ + } s.cursor++ + return nil + } + for { if idx < d.alen { if err := d.valueDecoder.DecodeStream(s, depth, unsafe.Pointer(uintptr(p)+uintptr(idx)*d.size)); err != nil { return err @@ -67,9 +75,11 @@ func (d *arrayDecoder) DecodeStream(s *Stream, depth int64, p unsafe.Pointer) er s.cursor++ return nil case ',': + s.cursor++ continue case nul: if s.read() { + s.cursor++ continue } goto ERROR