From b22100b162fab85df3a5c00a412277b3befe04c2 Mon Sep 17 00:00:00 2001 From: brarcher Date: Tue, 6 Nov 2012 04:11:49 +0000 Subject: [PATCH] no check for pointer!=NULL before dereferencing it punpack can return NULL. These unit tests were checking if elements inside of the return value are NULL, but not if the pointer itself is NULL. Additionally, a NULL check is unnecessary for a free. git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@665 64e312b2-a51f-0410-8e61-82d0ca0eb02a --- tests/check_check_pack.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/check_check_pack.c b/tests/check_check_pack.c index 48169a6..fe97424 100644 --- a/tests/check_check_pack.c +++ b/tests/check_check_pack.c @@ -270,7 +270,7 @@ START_TEST(test_ppack_onlyctx) close (filedes[1]); rmsg = punpack (filedes[0]); - ck_assert_msg (rmsg->msg == NULL, + ck_assert_msg (rmsg != NULL && rmsg->msg == NULL, "Result message should be NULL with only CTX"); ck_assert_msg (rmsg->fixture_line == -1, "Result loc line should be -1 with only CTX"); @@ -305,13 +305,13 @@ START_TEST(test_ppack_multictx) close (filedes[1]); rmsg = punpack (filedes[0]); - ck_assert_msg (rmsg->test_line == 5, + ck_assert_msg (rmsg != NULL && rmsg->test_line == 5, "Test loc not being preserved on CTX change"); ck_assert_msg (rmsg->fixture_line == -1, "Fixture not reset on CTX change"); - if (rmsg != NULL) - free (rmsg); + + free (rmsg); } END_TEST @@ -333,10 +333,10 @@ START_TEST(test_ppack_nofail) close (filedes[1]); rmsg = punpack (filedes[0]); - ck_assert_msg (rmsg->msg == NULL, + ck_assert_msg (rmsg != NULL && rmsg->msg == NULL, "Failure result should be NULL with no failure message"); - if (rmsg != NULL) - free (rmsg); + + free (rmsg); } END_TEST -- 2.40.0