Skip to content

Commit

Permalink
Don't assume a max length in fs::ShortName
Browse files Browse the repository at this point in the history
  • Loading branch information
arch1t3cht committed Dec 3, 2023
1 parent 9076a8b commit d8910f5
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion libaegisub/windows/fs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ using agi::charset::ConvertLocal;

namespace agi { namespace fs {
std::string ShortName(path const& p) {
std::wstring out(MAX_PATH + 1, 0);
DWORD length = GetShortPathName(p.c_str(), NULL, 0);
if (!length)
return p.string();

std::wstring out(length, 0);
DWORD len = GetShortPathName(p.c_str(), &out[0], out.size());
if (!len)
return p.string();
Expand Down

0 comments on commit d8910f5

Please sign in to comment.