mirror of
https://github.com/xenia-project/xenia.git
synced 2026-02-08 08:44:22 +01:00
[BASE] Prevent crashing if special characters are in the launch path
A path containing characters which cannot be converted to a multibyte string would fail and cause cxxopts to assign the cvar target to argument 0
This commit is contained in:
parent
00aba94b98
commit
0957b8725f
|
|
@ -96,8 +96,14 @@ bool ParseWin32LaunchArguments(
|
|||
char** argv = reinterpret_cast<char**>(alloca(sizeof(char*) * argc));
|
||||
for (int n = 0; n < argc; n++) {
|
||||
size_t len = std::wcstombs(nullptr, wargv[n], 0);
|
||||
argv[n] = reinterpret_cast<char*>(alloca(sizeof(char) * (len + 1)));
|
||||
std::wcstombs(argv[n], wargv[n], len + 1);
|
||||
|
||||
if (len != -1) {
|
||||
argv[n] = reinterpret_cast<char*>(alloca(sizeof(char) * (len + 1)));
|
||||
std::wcstombs(argv[n], wargv[n], len + 1);
|
||||
} else {
|
||||
// Prevent cxxopts from indexing out of bounds.
|
||||
argc--;
|
||||
}
|
||||
}
|
||||
|
||||
LocalFree(wargv);
|
||||
|
|
|
|||
Loading…
Reference in a new issue