1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-01 17:36:21 +03:00

Foundation Classes - Host resolving by itself #457

Fixed issue  when gethostbyname returns a nullptr, because the host can't resolve itself
This commit is contained in:
Pasukhin Dmitry 2025-03-23 15:52:48 +00:00 committed by GitHub
parent e1528a3657
commit 2912b4dadb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -139,8 +139,13 @@ TCollection_AsciiString OSD_Host::InternetAddress()
char buffer[16];
TCollection_AsciiString result, host;
host = HostName();
memcpy(&internet_address, gethostbyname(host.ToCString()), sizeof(struct hostent));
host = HostName();
const auto* aHostByName = gethostbyname(host.ToCString());
if (aHostByName == nullptr)
{
aHostByName = gethostbyname("localhost");
}
memcpy(&internet_address, aHostByName, sizeof(struct hostent));
// Gets each bytes into integers
a = (unsigned char)internet_address.h_addr_list[0][0];