mirror of
https://github.com/wneessen/go-mail.git
synced 2024-11-22 22:00:49 +01:00
#136: 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:
parent
1c5c1e318c
commit
39080a8a05
1 changed files with 5 additions and 1 deletions
|
@ -230,8 +230,12 @@ func (mw *msgWriter) addFiles(fl []*File, a bool) {
|
||||||
}
|
}
|
||||||
if mw.d > 0 {
|
if mw.d > 0 {
|
||||||
mw.newPart(f.Header)
|
mw.newPart(f.Header)
|
||||||
|
mw.err = fmt.Errorf("ERROR")
|
||||||
|
}
|
||||||
|
|
||||||
|
if mw.err == nil {
|
||||||
|
mw.writeBody(f.Writer, e)
|
||||||
}
|
}
|
||||||
mw.writeBody(f.Writer, e)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue