Skip to content

Commit

Permalink
fix compression with LZ4_RAW when the output is incompressible (#282)
Browse files Browse the repository at this point in the history
  • Loading branch information
Achille authored Jul 25, 2022
1 parent aa19c25 commit 047e597
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions compress/lz4/lz4.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ func (c *Codec) Encode(dst, src []byte) ([]byte, error) {
n, err := compressor.CompressBlock(src, dst)
if err != nil { // see Decode for details about error handling
dst = make([]byte, 2*len(dst))
} else if n == 0 {
dst = reserveAtLeast(dst, lz4.CompressBlockBound(len(src)))
} else {
return dst[:n], nil
}
Expand Down

0 comments on commit 047e597

Please sign in to comment.