Fix decoding of struct type

This commit is contained in:
Masaaki Goshima 2021-02-15 18:45:58 +09:00
parent 9053c385ea
commit 98824e9bd9
1 changed files with 6 additions and 3 deletions

View File

@ -483,6 +483,7 @@ func (d *structDecoder) decodeStream(s *stream, p unsafe.Pointer) error {
} }
} }
s.cursor++ s.cursor++
s.skipWhiteSpace()
if s.char() == '}' { if s.char() == '}' {
s.cursor++ s.cursor++
return nil return nil
@ -551,10 +552,12 @@ func (d *structDecoder) decode(buf []byte, cursor int64, p unsafe.Pointer) (int6
default: default:
return 0, errNotAtBeginningOfValue(cursor) return 0, errNotAtBeginningOfValue(cursor)
} }
if buflen < 2 {
return 0, errUnexpectedEndOfJSON("object", cursor)
}
cursor++ cursor++
cursor = skipWhiteSpace(buf, cursor)
if buf[cursor] == '}' {
cursor++
return cursor, nil
}
for { for {
c, field, err := d.keyDecoder(d, buf, cursor) c, field, err := d.keyDecoder(d, buf, cursor)
if err != nil { if err != nil {