Commit 7b89865b authored by Markus Kauppila's avatar Markus Kauppila

Fixed potential memory leak from test case loading.

parent 43b873b8
......@@ -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 |
......
......@@ -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);
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment