FileSystem: Get rid of trailing nulls in GetWorkingDirectory()

This commit is contained in:
Connor McLaughlin 2021-12-17 20:44:08 +10:00
parent fa9e50d7c1
commit 592a591b5f

View file

@ -2480,11 +2480,17 @@ std::string GetWorkingDirectory()
while (!getcwd(buffer.data(), buffer.size())) while (!getcwd(buffer.data(), buffer.size()))
{ {
if (errno != ERANGE) if (errno != ERANGE)
return {}; {
buffer.clear();
break;
}
buffer.resize(buffer.size() * 2); buffer.resize(buffer.size() * 2);
} }
if (!buffer.empty())
buffer.resize(std::strlen(buffer.c_str()));
return buffer; return buffer;
} }