fix memory allocation issue

This commit is contained in:
Czarek Nakamoto
2024-04-20 16:52:51 +02:00
parent 162dfa6683
commit b736b3e465

View File

@@ -24,8 +24,11 @@ const char* vectorToString(const std::vector<std::string>& vec, const std::strin
}
result += vec.back(); // Append the last string without the separator
const char* cstr = result.c_str();
return cstr;
std::string str = result;
const std::string::size_type size = str.size();
char *buffer = new char[size + 1]; //we need extra char for NUL
memcpy(buffer, str.c_str(), size + 1);
return buffer;
}
const char* vectorToString(const std::vector<uint32_t>& vec, const std::string separator) {