mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-02-21 09:12:11 +08:00
make sure p->ifa_addr is not NULL before using it
This commit is contained in:
parent
b0184f1476
commit
a872d9c299
@ -931,7 +931,7 @@ static bool get_mac_address(unsigned char macaddr[MAC_ADDRESS_MAX_LEN],
|
||||
|
||||
if (getifaddrs(&ifap) == 0) {
|
||||
for (const ifaddrs *p = ifap; p; p = p->ifa_next) {
|
||||
if (p->ifa_addr->sa_family == AF_LINK) {
|
||||
if (p->ifa_addr && p->ifa_addr->sa_family == AF_LINK) {
|
||||
if (p->ifa_name && p->ifa_name[0] &&
|
||||
!strcmp((const char *)p->ifa_name, interface)) {
|
||||
const sockaddr_dl &sdl = *reinterpret_cast<sockaddr_dl *>(p->ifa_addr);
|
||||
|
Loading…
x
Reference in New Issue
Block a user