SDL_test_harness: fix memory leak when generated seed

This commit is contained in:
Sylvain 2023-01-16 10:28:16 +01:00
parent c638b4a682
commit 5d1e6b28d9
No known key found for this signature in database
GPG key ID: 5F87E02E5BC0939E

View file

@ -395,6 +395,7 @@ int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], const char *user
int testSkippedCount = 0;
int countSum = 0;
const SDLTest_TestCaseReference **failedTests;
char generatedSeed[16 + 1];
/* Sanitize test iterations */
if (testIterations < 1) {
@ -403,11 +404,14 @@ int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], const char *user
/* Generate run see if we don't have one already */
if (userRunSeed == NULL || userRunSeed[0] == '\0') {
runSeed = SDLTest_GenerateRunSeed(16);
if (runSeed == NULL) {
char *tmp = SDLTest_GenerateRunSeed(16);
if (tmp == NULL) {
SDLTest_LogError("Generating a random seed failed");
return 2;
}
SDL_memcpy(generatedSeed, tmp, 16 + 1);
SDL_free(tmp);
runSeed = generatedSeed;
} else {
runSeed = userRunSeed;
}