Skip to content

Commit

Permalink
CompressingReader: make sure to clear out buffer
Browse files Browse the repository at this point in the history
Out buffer may have some stale overflow data on Reset.

Signed-off-by: Alex Dubov <oakad@yahoo.com>
  • Loading branch information
oakad committed Nov 13, 2023
1 parent 65348f5 commit f2ece5b
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions compressing_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ func (zrd *CompressingReader) Reset(src io.ReadCloser) {
zrd.frame.Reset(1)
zrd.state = crStateInitial
zrd.src = src
zrd.out.clear()
}

type ovWriter struct {
Expand Down Expand Up @@ -208,3 +209,10 @@ func (wr *ovWriter) reset(out []byte) bool {
wr.data = out
return true
}

func (wr *ovWriter) clear() {
wr.data = nil
wr.dataPos = 0
wr.ov = wr.ov[ : 0]
wr.ovPos = 0
}

0 comments on commit f2ece5b

Please sign in to comment.