From cf117d320b223b2f6e64bef6b8663c0188ff075c Mon Sep 17 00:00:00 2001 From: Winni Neessen Date: Sat, 26 Oct 2024 21:07:04 +0200 Subject: [PATCH] Add nil check in testMessage helper function Added a conditional check to ensure 'NewMsg()' does not return nil in the 'testMessage' helper function. This update will prevent potential nil pointer dereferences and improve the robustness of the test. --- client_test.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/client_test.go b/client_test.go index e3d03c7..70032ba 100644 --- a/client_test.go +++ b/client_test.go @@ -3527,6 +3527,9 @@ func parseJSONLog(t *testing.T, buf *bytes.Buffer) logData { func testMessage(t *testing.T) *Msg { t.Helper() message := NewMsg() + if message == nil { + t.Fatal("failed to create new message") + } if err := message.From(TestSenderValid); err != nil { t.Errorf("failed to set sender address: %s", err) }