Skip to content

Commit

Permalink
fix a bug where nil line buffer would be put back
Browse files Browse the repository at this point in the history
  • Loading branch information
cyriltovena authored and slim-bean committed Aug 13, 2019
1 parent 001d36f commit a407099
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pkg/chunkenc/gzip.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bufio"
"bytes"
"encoding/binary"
"fmt"
"hash"
"hash/crc32"
"io"
Expand Down Expand Up @@ -546,6 +547,9 @@ func (si *bufferedIterator) moveNext() (int64, []byte, bool) {
BytesBufferPool.Put(si.buf)
}
si.buf = BytesBufferPool.Get(lineSize).([]byte)
if lineSize > cap(si.buf) {
fmt.Println("oups ", lineSize, " ", len(si.buf), " ", cap(si.buf))
}
}

// Then process reading the line.
Expand Down Expand Up @@ -576,7 +580,9 @@ func (si *bufferedIterator) Close() error {
si.closed = true
si.pool.PutReader(si.reader)
BufReaderPool.Put(si.s)
BytesBufferPool.Put(si.buf)
if si.buf != nil {
BytesBufferPool.Put(si.buf)
}
si.s = nil
si.buf = nil
si.decBuf = nil
Expand Down

0 comments on commit a407099

Please sign in to comment.