Handle case where server does not return body

This was causing a nil pointer dereference before.

Fixes ~migadu/alps#121.
This commit is contained in:
Drew DeVault 2020-10-22 11:03:59 -04:00
parent aaa30ead41
commit 793f261b62

View file

@ -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)