Refactor error checking in msg.SendErrorIsTemp()

Added an additional condition in the SendErrorIsTemp function within msg.go to ensure that the error e is not nil before referencing it. This guards against potential runtime panics from dereferencing a nil pointer, enhancing robustness of error handling.
This commit is contained in:
Winni Neessen 2023-11-29 16:45:25 +01:00
parent a50a3ceb18
commit ca896bd641
Signed by: wneessen
GPG key ID: 5F3AF39B820C119D

2
msg.go
View file

@ -1074,7 +1074,7 @@ func (m *Msg) HasSendError() bool {
// corresponding error was of temporary nature and should be retried later // corresponding error was of temporary nature and should be retried later
func (m *Msg) SendErrorIsTemp() bool { func (m *Msg) SendErrorIsTemp() bool {
var e *SendError var e *SendError
if errors.As(m.sendError, &e) { if errors.As(m.sendError, &e) && e != nil {
return e.isTemp return e.isTemp
} }
return false return false