From 3a471dc1649834ffa0bdf953063137f46172654e Mon Sep 17 00:00:00 2001 From: Moritz Grimm Date: Wed, 20 Sep 2017 11:20:39 +0200 Subject: [PATCH] Assert errstr2 to be not NULL before dereferencing it --- tests/check_cfg.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/check_cfg.c b/tests/check_cfg.c index 75b6f4f..0915aad 100644 --- a/tests/check_cfg.c +++ b/tests/check_cfg.c @@ -252,6 +252,7 @@ START_TEST(test_server_protocol) errstr2 = NULL; ck_assert_int_eq(cfg_set_server_protocol("invalid", &errstr2), -1); + ck_assert_ptr_ne(errstr2, NULL); ck_assert_str_eq(errstr2, "unsupported"); ck_assert_int_eq(cfg_set_server_protocol("hTtP", NULL), 0); @@ -500,27 +501,32 @@ START_TEST(test_metadata_format_str) errstr2 = NULL; ck_assert_int_eq(cfg_set_metadata_format_str(PLACEHOLDER_METADATA, &errstr2), -1); + ck_assert_ptr_ne(errstr2, NULL); ck_assert_str_eq(errstr2, "prohibited placeholder " PLACEHOLDER_METADATA); errstr2 = NULL; ck_assert_int_eq(cfg_set_metadata_format_str( PLACEHOLDER_TRACK PLACEHOLDER_TRACK, &errstr2), -1); + ck_assert_ptr_ne(errstr2, NULL); ck_assert_str_eq(errstr2, "duplicate placeholder " PLACEHOLDER_TRACK); errstr2 = NULL; ck_assert_int_eq(cfg_set_metadata_format_str( PLACEHOLDER_STRING PLACEHOLDER_STRING, &errstr2), -1); + ck_assert_ptr_ne(errstr2, NULL); ck_assert_str_eq(errstr2, "duplicate placeholder " PLACEHOLDER_STRING); errstr2 = NULL; ck_assert_int_eq(cfg_set_metadata_format_str( PLACEHOLDER_ARTIST PLACEHOLDER_ARTIST, &errstr2), -1); + ck_assert_ptr_ne(errstr2, NULL); ck_assert_str_eq(errstr2, "duplicate placeholder " PLACEHOLDER_ARTIST); errstr2 = NULL; ck_assert_int_eq(cfg_set_metadata_format_str( PLACEHOLDER_TITLE PLACEHOLDER_TITLE, &errstr2), -1); + ck_assert_ptr_ne(errstr2, NULL); ck_assert_str_eq(errstr2, "duplicate placeholder " PLACEHOLDER_TITLE); } END_TEST