From e0fbca02d4c22c92a69fb4f2e8cd4c37ef89979b Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Mon, 28 Feb 2022 13:24:25 +0000 Subject: [PATCH] compress: fix memory leak - fixes #6013 Before this change we forgot to close the compressor when checking to see if an object was compressible. --- backend/compress/compress.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/backend/compress/compress.go b/backend/compress/compress.go index fbd99ac9f..db90dca25 100644 --- a/backend/compress/compress.go +++ b/backend/compress/compress.go @@ -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 }