Skip to content

Commit

Permalink
Check that zlib writer and readers close correctly because we re-use …
Browse files Browse the repository at this point in the history
…them from the pool
  • Loading branch information
fredli74 committed Jul 27, 2024
1 parent 0d43dfd commit 7b82c97
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions core/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,9 @@ func ZlibCompress(src bytearray.ByteArray) (dst bytearray.ByteArray) {
src.ReadSeek(0, bytearray.SEEK_SET)
zw := zpool.GetWriter(&dst)
CopyOrPanic(zw, &src)
zw.Close()
if err := zw.Close(); err != nil {
panic(err)
}
zpool.PutWriter(zw)
return dst
}
Expand All @@ -186,7 +188,11 @@ func ZlibUncompress(src bytearray.ByteArray) (dst bytearray.ByteArray) {
if err != nil {
panic(err)
}
defer zr.Close()
defer func() {
if err := zr.Close(); err != nil {
panic(err)
}
}()
CopyOrPanic(&dst, zr)
return dst
}
Expand Down

0 comments on commit 7b82c97

Please sign in to comment.