diff options
author | Nguyễn Gia Phong <mcsinyx@disroot.org> | 2022-01-20 01:10:08 +0700 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2022-01-19 20:18:00 +0100 |
commit | 904ffacb0e521218ba1f41e2e5c26d9ac41c9969 (patch) | |
tree | 4bb0dbe000b1241586f7fb0635ee076f70c22fe2 /worker/lib/parse.go | |
parent | beae17a6da37402d1c69dc76b476f55cbae982b8 (diff) | |
download | aerc-904ffacb0e521218ba1f41e2e5c26d9ac41c9969.tar.gz |
maildir,notmuch: avoid leaking open files
Previously, Message.NewReader returned the wrapped buffered reader
without a reference to the opened file, so the files descriptors
were left unclosed after reading. Now, the file reader is returned
directly and closed on the call site. Buffering is not needed here
because it is an implementation detail of go-message.
Fixes: https://todo.sr.ht/~rjarry/aerc/9
Diffstat (limited to 'worker/lib/parse.go')
-rw-r--r-- | worker/lib/parse.go | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/worker/lib/parse.go b/worker/lib/parse.go index 87f94bdd..6d73a1f5 100644 --- a/worker/lib/parse.go +++ b/worker/lib/parse.go @@ -211,7 +211,7 @@ func parseAddressList(h *mail.Header, key string) ([]*mail.Address, error) { // RawMessage is an interface that describes a raw message type RawMessage interface { - NewReader() (io.Reader, error) + NewReader() (io.ReadCloser, error) ModelFlags() ([]models.Flag, error) Labels() ([]string, error) UID() uint32 @@ -225,6 +225,7 @@ func MessageInfo(raw RawMessage) (*models.MessageInfo, error) { if err != nil { return nil, err } + defer r.Close() msg, err := message.Read(r) if err != nil { return nil, fmt.Errorf("could not read message: %v", err) |