From 047f936ec7f14b0af84c90d03e24c79d4d3456a0 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Thu, 16 Jan 2025 13:11:31 +0200 Subject: [PATCH] lib-settings: test-settings-parser - Avoid crashing on unit test failure Also makes scan-build happy. --- src/lib-settings/test-settings-parser.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/lib-settings/test-settings-parser.c b/src/lib-settings/test-settings-parser.c index 2be78b9727..74642b399c 100644 --- a/src/lib-settings/test-settings-parser.c +++ b/src/lib-settings/test-settings-parser.c @@ -188,8 +188,13 @@ static void test_settings_parse_boollist_string(void) pool_datastack_create(), &output, &error) == 0, i); test_assert_idx(array_count(&output) == str_array_length(tests[i].output), i); unsigned int j = 0; - array_foreach_elem(&output, value) - test_assert_strcmp_idx(tests[i].output[j++], value, i); + array_foreach_elem(&output, value) { + const char *next_output = NULL; + if (tests[i].output != NULL && + tests[i].output[j] != NULL) + next_output = tests[i].output[j++]; + test_assert_strcmp_idx(next_output, value, i); + } } T_END; t_array_init(&output, 8); -- 2.47.3