Commit 6b4bd5a75924917e45c70d55596ac2d51267c19e

Ryan C. Gordon 2022-06-05T09:34:12

test_harness: Report if zero tests to run. Fixes static analysis complain about a potential malloc(0) call.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
diff --git a/src/test/SDL_test_harness.c b/src/test/SDL_test_harness.c
index 3a1f432..ec67d99 100644
--- a/src/test/SDL_test_harness.c
+++ b/src/test/SDL_test_harness.c
@@ -443,6 +443,11 @@ int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], const char *user
         }
     }
 
+    if (totalNumberOfTests == 0) {
+        SDLTest_LogError("No tests to run?");
+        return -1;
+    }
+
     /* Pre-allocate an array for tracking failed tests (potentially all test cases) */
     failedTests = (const SDLTest_TestCaseReference **)SDL_malloc(totalNumberOfTests * sizeof(SDLTest_TestCaseReference *));
     if (failedTests == NULL) {