Skip to content

Commit

Permalink
Revert "[vm/win] Use wide-character api for local hostname on Windows."
Browse files Browse the repository at this point in the history
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 <aam@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
  • Loading branch information
aam authored and Commit Queue committed Aug 14, 2023
1 parent e95e7b8 commit 987dbe0
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions runtime/bin/platform_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -218,14 +218,7 @@ bool Platform::LocalHostname(char* buffer, intptr_t buffer_length) {
if (!SocketBase::Initialize()) {
return false;
}
// 256 is max length per https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-gethostnamew#remarks
const int HOSTNAME_MAXLENGTH = 256;
wchar_t hostname_w[HOSTNAME_MAXLENGTH];
if (GetHostNameW(hostname_w, HOSTNAME_MAXLENGTH) != 0) {
return false;
}
return WideCharToMultiByte(CP_UTF8, 0, hostname_w, -1, buffer, buffer_length,
nullptr, nullptr) != 0;
return gethostname(buffer, buffer_length) == 0;
#endif
}

Expand Down

0 comments on commit 987dbe0

Please sign in to comment.