mirror of
https://github.com/wneessen/go-mail.git
synced 2024-11-09 15:32:54 +01:00
Fix potential null pointer exceptions in msg.go
This commit adds conditions in msg.go file to check if the header 'HeaderDispositionNotificationTo' key exists in the map 'm.genHeader' before trying to associate it with a value. This prevents potential null pointer exceptions.
This commit is contained in:
parent
fd313e23b6
commit
da21550dc9
1 changed files with 6 additions and 2 deletions
8
msg.go
8
msg.go
|
@ -520,7 +520,9 @@ func (m *Msg) RequestMDNTo(t ...string) error {
|
|||
}
|
||||
tl = append(tl, a.String())
|
||||
}
|
||||
m.genHeader[HeaderDispositionNotificationTo] = tl
|
||||
if _, ok := m.genHeader[HeaderDispositionNotificationTo]; ok {
|
||||
m.genHeader[HeaderDispositionNotificationTo] = tl
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -541,7 +543,9 @@ func (m *Msg) RequestMDNAddTo(t string) error {
|
|||
var tl []string
|
||||
tl = append(tl, m.genHeader[HeaderDispositionNotificationTo]...)
|
||||
tl = append(tl, a.String())
|
||||
m.genHeader[HeaderDispositionNotificationTo] = tl
|
||||
if _, ok := m.genHeader[HeaderDispositionNotificationTo]; ok {
|
||||
m.genHeader[HeaderDispositionNotificationTo] = tl
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue