#138: Add error handling to message writing process

In the updated version of msgwriter.go, an additional error handling process has been included. If an error is detected when creating a new part in the message writer, this error is stored and prevents executing the writeBody function. This fixes nil pointer dereference in `mw.writeBody` if an error occured previously.
This commit is contained in:
Winni Neessen 2023-08-08 10:59:10 +02:00
parent 832c0026b1
commit edd6051df3
Signed by: wneessen
GPG key ID: 385AC9889632126E

View file

@ -231,9 +231,12 @@ func (mw *msgWriter) addFiles(fl []*File, a bool) {
if mw.d > 0 {
mw.newPart(f.Header)
}
if mw.err == nil {
mw.writeBody(f.Writer, e)
}
}
}
// newPart creates a new MIME multipart io.Writer and sets the partwriter to it
func (mw *msgWriter) newPart(h map[string][]string) {