diff --git a/SystemTools.cxx b/SystemTools.cxx index eb2bec65fc..1a73b164b4 100644 --- a/SystemTools.cxx +++ b/SystemTools.cxx @@ -4725,8 +4725,11 @@ bool SystemTools::GetShortPath(const std::string& path, std::string& shortPath) std::wstring wtempPath = Encoding::ToWide(tempPath); DWORD ret = GetShortPathNameW(wtempPath.c_str(), NULL, 0); std::vector buffer(ret); - ret = GetShortPathNameW(wtempPath.c_str(), - &buffer[0], static_cast(buffer.size())); + if (ret != 0) + { + ret = GetShortPathNameW(wtempPath.c_str(), + &buffer[0], static_cast(buffer.size())); + } if (ret == 0) {