[PATCH alps] smtp: fix calling Close() twice
Export this patch
From: Konstantinos Koukas <contact@koukas.org>
---
plugins/base/smtp.go | 4 ----
1 file changed, 4 deletions(-)
diff --git a/plugins/base/smtp.go b/plugins/base/smtp.go
index 1809059..f406647 100644
--- a/plugins/base/smtp.go
+++ b/plugins/base/smtp.go
@@ -100,13 +100,11 @@ func writeAttachment(mw *mail.Writer, att Attachment) error {
if err != nil {
return fmt.Errorf("failed to create attachment: %v", err)
}
- defer aw.Close()
f, err := att.Open()
if err != nil {
return fmt.Errorf("failed to open attachment: %v", err)
}
- defer f.Close()
if _, err := io.Copy(aw, f); err != nil {
return fmt.Errorf("failed to write attachment: %v", err)
@@ -166,7 +164,6 @@ func (msg *OutgoingMessage) WriteTo(w io.Writer) error {
if err != nil {
return fmt.Errorf("failed to create text part: %v", err)
}
- defer tw.Close()
if _, err := io.WriteString(tw, msg.Text); err != nil {
return fmt.Errorf("failed to write text part: %v", err)
@@ -206,7 +203,6 @@ func sendMessage(c *smtp.Client, msg *OutgoingMessage) error {
if err != nil {
return fmt.Errorf("DATA failed: %v", err)
}
- defer w.Close()
if err := msg.WriteTo(w); err != nil {
return fmt.Errorf("failed to write outgoing message: %v", err)
--
2.34.4
alps/patches/.build.yml: SUCCESS in 59s
[smtp: fix calling Close() twice][0] from [~koukas][1]
[0]: https://lists.sr.ht/~migadu/alps-devel/patches/36198
[1]: mailto:contact@koukas.org
✓ #864920 SUCCESS alps/patches/.build.yml https://builds.sr.ht/~migadu/job/864920
These are intentional, to ensure we call Close on error.