From 793f261b626be09c50c5b67b3dba56c97e0ce979 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Thu, 22 Oct 2020 11:03:59 -0400 Subject: Handle case where server does not return body This was causing a nil pointer dereference before. Fixes ~migadu/alps#121. --- plugins/base/imap.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/base/imap.go b/plugins/base/imap.go index db9a3f5..16bd2ef 100644 --- a/plugins/base/imap.go +++ b/plugins/base/imap.go @@ -510,7 +510,12 @@ func getMessagePart(conn *imapclient.Client, mboxName string, uid uint32, partPa return nil, nil, fmt.Errorf("server didn't return message") } - headerReader := bufio.NewReader(msg.GetBody(&partHeaderSection)) + body := msg.GetBody(&partHeaderSection) + if body == nil { + return nil, nil, fmt.Errorf("server didn't return message") + } + + headerReader := bufio.NewReader(body) h, err := textproto.ReadHeader(headerReader) if err != nil { return nil, nil, fmt.Errorf("failed to read part header: %v", err) -- cgit v1.2.3