fix Coverity issues

This commit is contained in:
wmayer
2016-09-03 14:51:28 +02:00
parent 9ed53fea38
commit 3c88edd007
4 changed files with 17 additions and 15 deletions

View File

@@ -169,31 +169,31 @@ std::string FileInfo::getTempFileName(const char* FileName, const char* Path)
return std::string(ConvertFromWideString(std::wstring(buf)));
#else
char buf[PATH_MAX+1];
std::string buf;
// Path where the file is located
if (Path)
std::strncpy(buf, Path, PATH_MAX);
buf = Path;
else
std::strncpy(buf, getTempPath().c_str(), PATH_MAX);
buf[PATH_MAX] = 0; // null termination needed
buf = getTempPath();
// File name in the path
if (FileName) {
std::strcat(buf, "/");
std::strcat(buf, FileName);
std::strcat(buf, "XXXXXX");
buf += "/";
buf += FileName;
buf += "XXXXXX";
}
else {
buf += "/fileXXXXXX";
}
else
std::strcat(buf, "/fileXXXXXX");
int id = mkstemp(buf);
int id = mkstemp(static_cast<char*>(buf.c_str());
if (id > -1) {
FILE* file = fdopen(id, "w");
fclose(file);
unlink(buf.c_str());
}
return std::string(buf);
return buf;
#endif
}