compress: fix memory leak - fixes #6013

Before this change we forgot to close the compressor when checking to
see if an object was compressible.
This commit is contained in:
Nick Craig-Wood 2022-02-28 13:24:25 +00:00
parent 21355b4208
commit e0fbca02d4

View File

@ -401,6 +401,10 @@ func isCompressible(r io.Reader) (bool, error) {
if err != nil {
return false, err
}
err = w.Close()
if err != nil {
return false, err
}
ratio := float64(n) / float64(b.Len())
return ratio > minCompressionRatio, nil
}