From 5dcbe712ae831332eaed5e83a427306ab7884db7 Mon Sep 17 00:00:00 2001 From: Winni Neessen Date: Wed, 29 Nov 2023 17:47:30 +0100 Subject: [PATCH] Add null check to prevent empty file handle error in msg_test.go Implemented a null check to ensure the 'fi' file handle is not empty. With the absence of this check, the test was continuing even when 'fi' was empty, leading to null pointer exceptions further down in the code. --- msg_test.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/msg_test.go b/msg_test.go index e25249e..8bf0de6 100644 --- a/msg_test.go +++ b/msg_test.go @@ -2589,6 +2589,10 @@ func TestMsg_WriteToFile(t *testing.T) { if err != nil { t.Errorf("failed to stat output file: %s", err) } + if fi == nil { + t.Errorf("received empty file handle") + return + } if fi.Size() <= 0 { t.Errorf("output file is expected to contain data but its size is zero") }