win: handle empty string in uv_get_process_title (#4807)
Distinguish between errors and "the console title is the empty string" when calling GetConsoleTitle. Both are signified by a return value of zero. No test because I couldn't think of a succinct way to programmatically create a new console window with an empty title. Fixes: https://github.com/nodejs/node/issues/58695
This commit is contained in:
parent
e13e80b20c
commit
0d4f54f0f6
@ -378,10 +378,15 @@ done:
|
|||||||
static int uv__get_process_title(void) {
|
static int uv__get_process_title(void) {
|
||||||
WCHAR title_w[MAX_TITLE_LENGTH];
|
WCHAR title_w[MAX_TITLE_LENGTH];
|
||||||
DWORD wlen;
|
DWORD wlen;
|
||||||
|
DWORD err;
|
||||||
|
|
||||||
|
SetLastError(ERROR_SUCCESS);
|
||||||
wlen = GetConsoleTitleW(title_w, sizeof(title_w) / sizeof(WCHAR));
|
wlen = GetConsoleTitleW(title_w, sizeof(title_w) / sizeof(WCHAR));
|
||||||
if (wlen == 0)
|
if (wlen == 0) {
|
||||||
return uv_translate_sys_error(GetLastError());
|
err = GetLastError();
|
||||||
|
if (err != 0)
|
||||||
|
return uv_translate_sys_error(err);
|
||||||
|
}
|
||||||
|
|
||||||
return uv__convert_utf16_to_utf8(title_w, wlen, &process_title);
|
return uv__convert_utf16_to_utf8(title_w, wlen, &process_title);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user