mirror of
https://github.com/wneessen/go-mail.git
synced 2024-12-22 18:50:37 +01:00
Refactored null checks in msgwriter.go
Extended null check conditions in msgwriter.go to prevent potential nil pointer dereference. This change ensures robustness in error handling in scenarios where FROM header or envelope FROM is either not existent or nil.
This commit is contained in:
parent
ca896bd641
commit
b63d4803f1
1 changed files with 3 additions and 3 deletions
|
@ -67,13 +67,13 @@ func (mw *msgWriter) writeMsg(m *Msg) {
|
|||
// Set the FROM header (or envelope FROM if FROM is empty)
|
||||
hf := true
|
||||
f, ok := m.addrHeader[HeaderFrom]
|
||||
if !ok || len(f) == 0 {
|
||||
if !ok || (len(f) == 0 || f == nil) {
|
||||
f, ok = m.addrHeader[HeaderEnvelopeFrom]
|
||||
if !ok || len(f) == 0 {
|
||||
if !ok || (len(f) == 0 || f == nil) {
|
||||
hf = false
|
||||
}
|
||||
}
|
||||
if hf {
|
||||
if hf && (len(f) > 0 && f[0] != nil) {
|
||||
mw.writeHeader(Header(HeaderFrom), f[0].String())
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue