diff --git a/src/common/file_system.cpp b/src/common/file_system.cpp index 4cf26011a..5642d17be 100644 --- a/src/common/file_system.cpp +++ b/src/common/file_system.cpp @@ -2480,11 +2480,17 @@ std::string GetWorkingDirectory() while (!getcwd(buffer.data(), buffer.size())) { if (errno != ERANGE) - return {}; + { + buffer.clear(); + break; + } buffer.resize(buffer.size() * 2); } + if (!buffer.empty()) + buffer.resize(std::strlen(buffer.c_str())); + return buffer; }