Base: avoid const_cast in FileInfo
This commit is contained in:
@@ -181,11 +181,18 @@ std::string FileInfo::getTempFileName(const char* FileName, const char* Path)
|
||||
buf += "/fileXXXXXX";
|
||||
}
|
||||
|
||||
std::vector<char> vec;
|
||||
std::copy(buf.begin(), buf.end(), std::back_inserter(vec));
|
||||
vec.push_back('\0');
|
||||
|
||||
/* coverity[secure_temp] mkstemp uses 0600 as the mode and is safe */
|
||||
int id = mkstemp(const_cast<char*>(buf.c_str()));
|
||||
int id = mkstemp(vec.data());
|
||||
if (id > -1) {
|
||||
FILE* file = fdopen(id, "w");
|
||||
fclose(file);
|
||||
vec.pop_back(); // remove '\0'
|
||||
std::string str(vec.begin(), vec.end());
|
||||
buf.swap(str);
|
||||
unlink(buf.c_str());
|
||||
}
|
||||
return buf;
|
||||
|
||||
Reference in New Issue
Block a user