网卡ipv6地址不存在kdk_nc_get_ipv6接口返回NULL

This commit is contained in:
sunzhen 2024-06-05 11:13:46 +08:00
parent e21a33a579
commit 9cba84f025
1 changed files with 29 additions and 24 deletions

View File

@ -433,6 +433,8 @@ char **_get_nc_cfg(const char *nc, enum cardcfg cfg)
} }
} }
if(strlen(addr) != 0)
{
res = malloc(sizeof(char *)); res = malloc(sizeof(char *));
if (!res) if (!res)
{ {
@ -460,6 +462,7 @@ char **_get_nc_cfg(const char *nc, enum cardcfg cfg)
freeifaddrs(ifap); freeifaddrs(ifap);
} }
}
break; break;
default: default:
break; break;
@ -528,10 +531,12 @@ char *kdk_nc_get_private_ipv6(const char *nc)
if (!nc) if (!nc)
return NULL; return NULL;
char *ipv6 = NULL;
char **ipv6list = _get_nc_cfg(nc, NCCFG_IPv6); char **ipv6list = _get_nc_cfg(nc, NCCFG_IPv6);
if (!ipv6list) if (!ipv6list)
return NULL; return NULL;
char *ipv6 = ipv6list[0]; ipv6 = ipv6list[0];
free(ipv6list); free(ipv6list);
return ipv6; return ipv6;
} }