Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Fixed potential memory leak from test case loading.
Browse files Browse the repository at this point in the history
  • Loading branch information
mkauppila committed Jul 29, 2011
1 parent 487f879 commit 32a3923
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions test/test-automation/fuzzer/fuzzer.c
Expand Up @@ -50,6 +50,7 @@ GenerateExecKey(char *runSeed, char *suiteName,

char *execKey = md5Context.digest;

//! \todo could this be enhanced?
int key = execKey[4] << 24 |
execKey[9] << 16 |
execKey[13] << 8 |
Expand Down
16 changes: 16 additions & 0 deletions test/test-automation/runner.c
Expand Up @@ -264,6 +264,7 @@ ScanForTestSuites(char *directoryName, char *extension)
SDL_free(reference);
return NULL;
}

SDL_snprintf(reference->directoryPath, dpSize, "%s%s.%s",
directoryName, name, ext);

Expand Down Expand Up @@ -398,16 +399,31 @@ LoadTestCases(TestSuiteReference *suites)
// copy suite name
int length = SDL_strlen(suiteReference->name) + 1;
item->suiteName = SDL_malloc(length);
if(item->suiteName == NULL) {
SDL_free(item);
return NULL;
}
strncpy(item->suiteName, suiteReference->name, length);

// copy test name
length = SDL_strlen(testReference->name) + 1;
item->testName = SDL_malloc(length);
if(item->testName == NULL) {
SDL_free(item->suiteName);
SDL_free(item);
return NULL;
}
strncpy(item->testName, testReference->name, length);

// copy test description
length = SDL_strlen(testReference->description) + 1;
item->description = SDL_malloc(length);
if(item->description == NULL) {
SDL_free(item->description);
SDL_free(item->suiteName);
SDL_free(item);
return NULL;
}
strncpy(item->description, testReference->description, length);

item->requirements = testReference->requirements;
Expand Down

0 comments on commit 32a3923

Please sign in to comment.