From dbd3e787fe4cf977c2da7c58f7505918eb293e6c Mon Sep 17 00:00:00 2001 From: Sven van Haastregt Date: Thu, 18 Mar 2021 21:46:05 +0000 Subject: [PATCH] Do not dereference null pointer for no matching tests (#1191) When invoking for example test_c11_atomics test-that-does-not-exist parseAndCallCommandLineTests() would attempt to dereference `resultTestList` which is still a null pointer. Signed-off-by: Sven van Haastregt --- test_common/harness/testHarness.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/test_common/harness/testHarness.cpp b/test_common/harness/testHarness.cpp index 6b4c7201..5d96c43f 100644 --- a/test_common/harness/testHarness.cpp +++ b/test_common/harness/testHarness.cpp @@ -713,20 +713,20 @@ int parseAndCallCommandLineTests(int argc, const char *argv[], ret = saveResultsToJson(filename, argv[0], testList, selectedTestList, resultTestList, testNum); } - } - if (std::any_of(resultTestList, resultTestList + testNum, - [](test_status result) { - switch (result) - { - case TEST_PASS: - case TEST_SKIP: return false; - case TEST_FAIL: - default: return true; - }; - })) - { - ret = EXIT_FAILURE; + if (std::any_of(resultTestList, resultTestList + testNum, + [](test_status result) { + switch (result) + { + case TEST_PASS: + case TEST_SKIP: return false; + case TEST_FAIL: + default: return true; + }; + })) + { + ret = EXIT_FAILURE; + } } free(selectedTestList);