Avoid array-bounds error when debug/fortify enabled

This code causes GCC to error out due to a bounds error with the following set

	-D_GLIBCXX_DEBUG
	-D_FORTIFY_SOURCE=2

The solution is to copy via iterator.
This commit is contained in:
Derrick Lyndon Pallas 2019-04-22 20:19:14 +00:00 committed by Chang, Harry
parent 356c0ab3d4
commit e15954a4bd

View File

@ -56,9 +56,8 @@ std::string inferExpressionPath(const std::string &sigFile) {
// POSIX variant.
// dirname() may modify its argument, so we must make a copy.
std::vector<char> path(sigFile.size() + 1);
memcpy(path.data(), sigFile.c_str(), sigFile.size());
path[sigFile.size()] = 0; // ensure null termination.
std::vector<char> path(sigFile.begin(), sigFile.end());
path.push_back(0); // ensure null termination.
std::string rv = dirname(path.data());
#else