Skip to content

Commit

Permalink
SDL_test_harness: fix memory leak when generated seed
Browse files Browse the repository at this point in the history
  • Loading branch information
1bsyl committed Jan 16, 2023
1 parent 1a47cf5 commit 69253c5
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/test/SDL_test_harness.c
Expand Up @@ -389,6 +389,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) {
Expand All @@ -397,11 +398,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;
}
Expand Down

0 comments on commit 69253c5

Please sign in to comment.