aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorVincent Richard <[email protected]>2013-11-28 20:17:17 +0000
committerVincent Richard <[email protected]>2013-11-28 20:17:17 +0000
commit2232b60430c8ea3a994c6f0ea18b3bee44e726ac (patch)
tree8676073f0682306635ff6aad0269ed1152f257e7 /tests
parentMissing code documentation. (diff)
downloadvmime-2232b60430c8ea3a994c6f0ea18b3bee44e726ac.tar.gz
vmime-2232b60430c8ea3a994c6f0ea18b3bee44e726ac.zip
Fixed possible segfault caused by use of static string.
Diffstat (limited to 'tests')
-rw-r--r--tests/testRunner.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/tests/testRunner.cpp b/tests/testRunner.cpp
index 3286e23a..48a09d17 100644
--- a/tests/testRunner.cpp
+++ b/tests/testRunner.cpp
@@ -217,10 +217,11 @@ const std::string getFileNameFromPath(const std::string& path)
}
+static char g_moduleNameBuffer[2048];
+
+
const char* getTestModuleNameFromSourceFile(const char *path_)
{
- static std::string moduleName;
-
static const std::string testRunnerPath(getNormalizedPath(__FILE__));
static const std::string testRunnerFileName(getFileNameFromPath(testRunnerPath));
@@ -235,9 +236,11 @@ const char* getTestModuleNameFromSourceFile(const char *path_)
const std::string testPath(path.begin() + basePath.length(), path.end());
// "module/testFile.cpp" --> "module"
- moduleName = testPath.substr(0, testPath.length() - testFileName.length() - 1);
+ const std::string moduleName(testPath.substr(0, testPath.length() - testFileName.length() - 1));
+ std::copy(moduleName.begin(), moduleName.end(), g_moduleNameBuffer);
+ g_moduleNameBuffer[moduleName.length()] = 0;
- return moduleName.c_str();
+ return g_moduleNameBuffer;
}