netctl: Add null check for gethostbyname output.

This commit is contained in:
squidbus 2024-11-01 03:57:43 -07:00
parent 9ec75c3feb
commit 4c535c0b29

View File

@ -170,7 +170,7 @@ int PS4_SYSV_ABI sceNetCtlGetInfo(int code, OrbisNetCtlInfo* info) {
"127.0.0.1"); // placeholder in case gethostbyname can't find another ip "127.0.0.1"); // placeholder in case gethostbyname can't find another ip
char devname[80]; char devname[80];
gethostname(devname, 80); gethostname(devname, 80);
struct hostent* resolved = gethostbyname(devname); if (struct hostent* resolved = gethostbyname(devname)) {
for (int i = 0; resolved->h_addr_list[i] != nullptr; ++i) { for (int i = 0; resolved->h_addr_list[i] != nullptr; ++i) {
struct in_addr addrIn; struct in_addr addrIn;
memcpy(&addrIn, resolved->h_addr_list[i], sizeof(u32)); memcpy(&addrIn, resolved->h_addr_list[i], sizeof(u32));
@ -180,6 +180,7 @@ int PS4_SYSV_ABI sceNetCtlGetInfo(int code, OrbisNetCtlInfo* info) {
break; break;
} }
} }
}
break; break;
} }
default: default: