win: fix uv_get_process_title

Fixes: https://github.com/libuv/libuv/issues/2667
This commit is contained in:
StefanStojanovic 2026-02-04 15:13:37 +01:00 committed by Saúl Ibarra Corretgé
parent 71801576eb
commit 01f4f89503

View File

@ -376,17 +376,12 @@ done:
static int uv__get_process_title(void) {
WCHAR title_w[MAX_TITLE_LENGTH];
WCHAR title_w[MAX_PATH];
DWORD wlen;
DWORD err;
SetLastError(ERROR_SUCCESS);
wlen = GetConsoleTitleW(title_w, sizeof(title_w) / sizeof(WCHAR));
if (wlen == 0) {
err = GetLastError();
if (err != 0)
return uv_translate_sys_error(err);
}
wlen = GetModuleFileNameW(NULL, title_w, MAX_PATH);
if (wlen == 0)
return uv_translate_sys_error(GetLastError());
return uv__convert_utf16_to_utf8(title_w, wlen, &process_title);
}