mirror of https://github.com/OpenTTD/OpenTTD
Codefix: Don't copy path string to itself.
When determining base paths on Windows the path is converted to UCS-16, and then copied into the same buffer.pull/12857/head
parent
e22eb89b92
commit
b37954722b
|
@ -274,7 +274,7 @@ void DetermineBasePaths(const char *exe)
|
||||||
} else {
|
} else {
|
||||||
/* Use the folder of the config file as working directory. */
|
/* Use the folder of the config file as working directory. */
|
||||||
wchar_t config_dir[MAX_PATH];
|
wchar_t config_dir[MAX_PATH];
|
||||||
wcsncpy(path, convert_to_fs(_config_file, path, lengthof(path)), lengthof(path));
|
convert_to_fs(_config_file, path, lengthof(path));
|
||||||
if (!GetFullPathName(path, static_cast<DWORD>(std::size(config_dir)), config_dir, nullptr)) {
|
if (!GetFullPathName(path, static_cast<DWORD>(std::size(config_dir)), config_dir, nullptr)) {
|
||||||
Debug(misc, 0, "GetFullPathName failed ({})", GetLastError());
|
Debug(misc, 0, "GetFullPathName failed ({})", GetLastError());
|
||||||
_searchpaths[SP_WORKING_DIR].clear();
|
_searchpaths[SP_WORKING_DIR].clear();
|
||||||
|
@ -292,7 +292,7 @@ void DetermineBasePaths(const char *exe)
|
||||||
_searchpaths[SP_BINARY_DIR].clear();
|
_searchpaths[SP_BINARY_DIR].clear();
|
||||||
} else {
|
} else {
|
||||||
wchar_t exec_dir[MAX_PATH];
|
wchar_t exec_dir[MAX_PATH];
|
||||||
wcsncpy(path, convert_to_fs(exe, path, std::size(path)), std::size(path));
|
convert_to_fs(exe, path, std::size(path));
|
||||||
if (!GetFullPathName(path, static_cast<DWORD>(std::size(exec_dir)), exec_dir, nullptr)) {
|
if (!GetFullPathName(path, static_cast<DWORD>(std::size(exec_dir)), exec_dir, nullptr)) {
|
||||||
Debug(misc, 0, "GetFullPathName failed ({})", GetLastError());
|
Debug(misc, 0, "GetFullPathName failed ({})", GetLastError());
|
||||||
_searchpaths[SP_BINARY_DIR].clear();
|
_searchpaths[SP_BINARY_DIR].clear();
|
||||||
|
|
Loading…
Reference in New Issue