fix array stream decoder

This commit is contained in:
IncSW 2021-06-15 19:05:12 +03:00
parent 1037421a83
commit 9a2f108208
No known key found for this signature in database
GPG Key ID: 89876FA64BFB2D57
1 changed files with 11 additions and 1 deletions

View File

@ -46,8 +46,16 @@ func (d *arrayDecoder) DecodeStream(s *Stream, depth int64, p unsafe.Pointer) er
return nil return nil
case '[': case '[':
idx := 0 idx := 0
for {
s.cursor++ 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 idx < d.alen {
if err := d.valueDecoder.DecodeStream(s, depth, unsafe.Pointer(uintptr(p)+uintptr(idx)*d.size)); err != nil { if err := d.valueDecoder.DecodeStream(s, depth, unsafe.Pointer(uintptr(p)+uintptr(idx)*d.size)); err != nil {
return err return err
@ -67,9 +75,11 @@ func (d *arrayDecoder) DecodeStream(s *Stream, depth int64, p unsafe.Pointer) er
s.cursor++ s.cursor++
return nil return nil
case ',': case ',':
s.cursor++
continue continue
case nul: case nul:
if s.read() { if s.read() {
s.cursor++
continue continue
} }
goto ERROR goto ERROR