mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-30 14:53:11 +00:00
make sure p->ifa_addr is not NULL before using it
This commit is contained in:
parent
b0184f1476
commit
a872d9c299
1 changed files with 1 additions and 1 deletions
|
@ -931,7 +931,7 @@ static bool get_mac_address(unsigned char macaddr[MAC_ADDRESS_MAX_LEN],
|
||||||
|
|
||||||
if (getifaddrs(&ifap) == 0) {
|
if (getifaddrs(&ifap) == 0) {
|
||||||
for (const ifaddrs *p = ifap; p; p = p->ifa_next) {
|
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] &&
|
if (p->ifa_name && p->ifa_name[0] &&
|
||||||
!strcmp((const char *)p->ifa_name, interface)) {
|
!strcmp((const char *)p->ifa_name, interface)) {
|
||||||
const sockaddr_dl &sdl = *reinterpret_cast<sockaddr_dl *>(p->ifa_addr);
|
const sockaddr_dl &sdl = *reinterpret_cast<sockaddr_dl *>(p->ifa_addr);
|
||||||
|
|
Loading…
Reference in a new issue