Skip to content

Commit

Permalink
Discard buffer after not finding separator
Browse files Browse the repository at this point in the history
  • Loading branch information
kaiburjack committed Feb 2, 2022
1 parent 79e946a commit 17a2c1d
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions decoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,8 @@ func (thiz *decoder) readSimpleName() ([]byte, byte, error) {
return thiz.bb[i:len(thiz.bb)], thiz.r.buf[k], nil
}
}
thiz.bb = append(thiz.bb, thiz.r.buf[thiz.r.r:thiz.r.w]...)
thiz.r.discardBuffer()
err := thiz.r.read0()
if err != nil {
return nil, 0, err
Expand Down Expand Up @@ -427,11 +429,8 @@ func (thiz *decoder) readString(b byte) ([]byte, bool, error) {
return thiz.bb[i:len(thiz.bb)], singleQuote, nil
}
thiz.bb = append(thiz.bb, thiz.r.buf[thiz.r.r:thiz.r.w]...)
_, err := thiz.r.discard(thiz.r.w - j)
if err != nil {
return nil, false, err
}
err = thiz.r.read0()
thiz.r.discardBuffer()
err := thiz.r.read0()
if err != nil {
return nil, false, err
}
Expand Down

0 comments on commit 17a2c1d

Please sign in to comment.