fix: mismatched between len(s.buf) and s.bufSize

close #348
This commit is contained in:
Nao Yonashiro 2022-03-18 23:31:33 +09:00
parent fdf5700bcb
commit 6832682204
2 changed files with 12 additions and 1 deletions

View File

@ -3859,3 +3859,14 @@ func TestIssue337(t *testing.T) {
t.Fatal("unexpected result", m)
}
}
func TestIssue348(t *testing.T) {
in := strings.Repeat("["+strings.Repeat(",1000", 500)[1:]+"]", 2)
dec := json.NewDecoder(strings.NewReader(in))
for dec.More() {
var foo interface{}
if err := dec.Decode(&foo); err != nil {
t.Error(err)
}
}
}

View File

@ -103,7 +103,7 @@ func (s *Stream) statForRetry() ([]byte, int64, unsafe.Pointer) {
func (s *Stream) Reset() {
s.reset()
s.bufSize = initBufSize
s.bufSize = int64(len(s.buf))
}
func (s *Stream) More() bool {