Skip to content
This repository was archived by the owner on Jul 19, 2024. It is now read-only.

Commit 8eac2f3

Browse files
authored
Update launcher.cpp
1 parent 5d38623 commit 8eac2f3

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

Diff for: launcher/launcher.cpp

+4-8
Original file line numberDiff line numberDiff line change
@@ -77,20 +77,16 @@ void set_env_var(const std::wstring& name, const std::wstring& value)
7777

7878
fs::path get_launcher_directory()
7979
{
80-
size_t buffer_size = GetModuleFileNameW(nullptr, nullptr, 0);
81-
auto* buffer = new wchar_t[buffer_size + 1];
80+
wchar_t buffer[MAX_PATH];
81+
size_t buffer_size = GetModuleFileNameW(nullptr, &buffer[0], NAX_PATH);
8282

8383
fs::path path = fs::current_path();
8484

8585
if (buffer_size > 0) {
86-
size_t len = GetModuleFileNameW(nullptr, buffer, buffer_size + 1);
87-
fs::path launcher_path(std::wstring_view { buffer, len });
88-
86+
fs::path launcher_path(std::wstring_view { &buffer[0], buffer_size });
8987
path = launcher_path.parent_path();
9088
}
9189

92-
delete buffer;
93-
9490
return path;
9591
}
9692

@@ -245,4 +241,4 @@ int main()
245241
CloseHandle(pi.hThread);
246242

247243
return status;
248-
}
244+
}

0 commit comments

Comments
 (0)