From ea2fcb94381472fe9aae5fcaaba450226f728226 Mon Sep 17 00:00:00 2001 From: Daniel Huigens Date: Sat, 27 Apr 2019 07:31:29 +0200 Subject: [PATCH] Handle encrypt error in EncryptAttachment --- crypto/attachment.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/crypto/attachment.go b/crypto/attachment.go index e1409d3..ef931d4 100644 --- a/crypto/attachment.go +++ b/crypto/attachment.go @@ -75,14 +75,13 @@ func (pm *PmCrypto) encryptAttachment(estimatedSize int, fileName string, public var ew io.WriteCloser var encryptErr error ew, encryptErr = openpgp.Encrypt(writer, publicKey.entities, nil, hints, config) + if encryptErr != nil { + return nil, encryptErr + } attachmentProc.w = &ew attachmentProc.pipe = writer - if attachmentProc.err != nil { - attachmentProc.err = encryptErr - } return attachmentProc, nil - } // Use: ios/android only