Fixed potential memory leak from test case loading.
This commit is contained in:
parent
43b873b89a
commit
7b89865bd4
2 changed files with 17 additions and 0 deletions
|
@ -50,6 +50,7 @@ GenerateExecKey(char *runSeed, char *suiteName,
|
||||||
|
|
||||||
char *execKey = md5Context.digest;
|
char *execKey = md5Context.digest;
|
||||||
|
|
||||||
|
//! \todo could this be enhanced?
|
||||||
int key = execKey[4] << 24 |
|
int key = execKey[4] << 24 |
|
||||||
execKey[9] << 16 |
|
execKey[9] << 16 |
|
||||||
execKey[13] << 8 |
|
execKey[13] << 8 |
|
||||||
|
|
|
@ -264,6 +264,7 @@ ScanForTestSuites(char *directoryName, char *extension)
|
||||||
SDL_free(reference);
|
SDL_free(reference);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_snprintf(reference->directoryPath, dpSize, "%s%s.%s",
|
SDL_snprintf(reference->directoryPath, dpSize, "%s%s.%s",
|
||||||
directoryName, name, ext);
|
directoryName, name, ext);
|
||||||
|
|
||||||
|
@ -398,16 +399,31 @@ LoadTestCases(TestSuiteReference *suites)
|
||||||
// copy suite name
|
// copy suite name
|
||||||
int length = SDL_strlen(suiteReference->name) + 1;
|
int length = SDL_strlen(suiteReference->name) + 1;
|
||||||
item->suiteName = SDL_malloc(length);
|
item->suiteName = SDL_malloc(length);
|
||||||
|
if(item->suiteName == NULL) {
|
||||||
|
SDL_free(item);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
strncpy(item->suiteName, suiteReference->name, length);
|
strncpy(item->suiteName, suiteReference->name, length);
|
||||||
|
|
||||||
// copy test name
|
// copy test name
|
||||||
length = SDL_strlen(testReference->name) + 1;
|
length = SDL_strlen(testReference->name) + 1;
|
||||||
item->testName = SDL_malloc(length);
|
item->testName = SDL_malloc(length);
|
||||||
|
if(item->testName == NULL) {
|
||||||
|
SDL_free(item->suiteName);
|
||||||
|
SDL_free(item);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
strncpy(item->testName, testReference->name, length);
|
strncpy(item->testName, testReference->name, length);
|
||||||
|
|
||||||
// copy test description
|
// copy test description
|
||||||
length = SDL_strlen(testReference->description) + 1;
|
length = SDL_strlen(testReference->description) + 1;
|
||||||
item->description = SDL_malloc(length);
|
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);
|
strncpy(item->description, testReference->description, length);
|
||||||
|
|
||||||
item->requirements = testReference->requirements;
|
item->requirements = testReference->requirements;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue