diff --git a/cmd/utils.go b/cmd/utils.go index d5a44c2b2..30d6d0e3b 100644 --- a/cmd/utils.go +++ b/cmd/utils.go @@ -42,7 +42,7 @@ import ( "sync" "time" - humanize "github.com/dustin/go-humanize" + "github.com/dustin/go-humanize" "github.com/gorilla/mux" "github.com/minio/madmin-go" miniogopolicy "github.com/minio/minio-go/v7/pkg/policy" diff --git a/internal/ioutil/odirect_reader.go b/internal/ioutil/odirect_reader.go index aaffca784..c51f82fc7 100644 --- a/internal/ioutil/odirect_reader.go +++ b/internal/ioutil/odirect_reader.go @@ -122,10 +122,15 @@ func (o *ODirectReader) Read(buf []byte) (n int, err error) { // Close - Release the buffer and close the file. func (o *ODirectReader) Close() error { - if o.SmallFile { - ODirectPoolSmall.Put(o.bufp) - } else { - ODirectPoolLarge.Put(o.bufp) + if o.bufp != nil { + if o.SmallFile { + ODirectPoolSmall.Put(o.bufp) + } else { + ODirectPoolLarge.Put(o.bufp) + } + o.bufp = nil + o.buf = nil } + o.err = errors.New("internal error: ODirectReader Read after Close") return o.File.Close() }