Fix stream buffer length

This commit is contained in:
Masaaki Goshima 2021-06-06 10:52:55 +09:00
parent 5e281e340f
commit 3c0e1b5e8c
1 changed files with 2 additions and 1 deletions

View File

@ -198,6 +198,7 @@ func (s *Stream) readBuf() []byte {
} }
remainNotNulCharNum++ remainNotNulCharNum++
} }
s.length = s.cursor + remainNotNulCharNum
return s.buf[s.cursor+remainNotNulCharNum:] return s.buf[s.cursor+remainNotNulCharNum:]
} }
@ -209,7 +210,7 @@ func (s *Stream) read() bool {
last := len(buf) - 1 last := len(buf) - 1
buf[last] = nul buf[last] = nul
n, err := s.r.Read(buf[:last]) n, err := s.r.Read(buf[:last])
s.length = s.cursor + int64(n) s.length += int64(n)
if n == last { if n == last {
s.filledBuffer = true s.filledBuffer = true
} else { } else {