Commit 8e643b9b authored by Brad King's avatar Brad King
Browse files

SystemTools: Fix crash in GetShortPath

When `GetShortPathNameW` returns a 0 buffer size then we should not call
it again.

Change-Id: I6529013ec3c792796649c25168f6c67b60ac7238
parent 6d23dd7e
......@@ -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<wchar_t> buffer(ret);
ret = GetShortPathNameW(wtempPath.c_str(),
&buffer[0], static_cast<DWORD>(buffer.size()));
if (ret != 0)
{
ret = GetShortPathNameW(wtempPath.c_str(),
&buffer[0], static_cast<DWORD>(buffer.size()));
}
if (ret == 0)
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment