Skip to content

Commit 987dbe0

Browse files
aamCommit Queue
authored and
Commit Queue
committed
Revert "[vm/win] Use wide-character api for local hostname on Windows."
This reverts commit 7bdbc05 as it makes dart crash on Windows 7 and earlier. Bug: flutter/flutter#130554 Change-Id: I61224ea89aec968465e2bc4fa1dafe0eca215677 TEST=ci Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/320620 Auto-Submit: Alexander Aprelev <[email protected]> Reviewed-by: Siva Annamalai <[email protected]> Commit-Queue: Alexander Aprelev <[email protected]> Commit-Queue: Siva Annamalai <[email protected]>
1 parent e95e7b8 commit 987dbe0

File tree

1 file changed

+1
-8
lines changed

1 file changed

+1
-8
lines changed

runtime/bin/platform_win.cc

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -218,14 +218,7 @@ bool Platform::LocalHostname(char* buffer, intptr_t buffer_length) {
218218
if (!SocketBase::Initialize()) {
219219
return false;
220220
}
221-
// 256 is max length per https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-gethostnamew#remarks
222-
const int HOSTNAME_MAXLENGTH = 256;
223-
wchar_t hostname_w[HOSTNAME_MAXLENGTH];
224-
if (GetHostNameW(hostname_w, HOSTNAME_MAXLENGTH) != 0) {
225-
return false;
226-
}
227-
return WideCharToMultiByte(CP_UTF8, 0, hostname_w, -1, buffer, buffer_length,
228-
nullptr, nullptr) != 0;
221+
return gethostname(buffer, buffer_length) == 0;
229222
#endif
230223
}
231224

0 commit comments

Comments
 (0)