aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2020-10-22 11:03:59 -0400
committerDrew DeVault <sir@cmpwn.com>2020-10-22 11:05:35 -0400
commit793f261b626be09c50c5b67b3dba56c97e0ce979 (patch)
treeb685d14925f6e983c37182ffe542ba40c1786597
parentaaa30ead41532fa920f3c5e0298ed52196d7fe3a (diff)
downloadalps-793f261b626be09c50c5b67b3dba56c97e0ce979.tar.gz
alps-793f261b626be09c50c5b67b3dba56c97e0ce979.zip
Handle case where server does not return body
This was causing a nil pointer dereference before. Fixes ~migadu/alps#121.
-rw-r--r--plugins/base/imap.go7
1 files changed, 6 insertions, 1 deletions
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)