8208676: Missing NULL check and resource leak in NetworkPerformanceInterface::NetworkPerformance::network_utilization

Reviewed-by: mgronlun, rehn
This commit is contained in:
Robin Westberg 2018-08-06 14:56:56 +02:00
parent 2f1aae720b
commit 961156b1d5
2 changed files with 3 additions and 1 deletions

View file

@ -1107,7 +1107,7 @@ int NetworkPerformanceInterface::NetworkPerformance::network_utilization(Network
NetworkInterface* ret = NULL;
for (cur_address = addresses; cur_address != NULL; cur_address = cur_address->ifa_next) {
if (cur_address->ifa_addr->sa_family != AF_PACKET) {
if ((cur_address->ifa_addr == NULL) || (cur_address->ifa_addr->sa_family != AF_PACKET)) {
continue;
}
@ -1118,6 +1118,7 @@ int NetworkPerformanceInterface::NetworkPerformance::network_utilization(Network
ret = cur;
}
freeifaddrs(addresses);
*network_interfaces = ret;
return OS_OK;

View file

@ -816,6 +816,7 @@ int NetworkPerformanceInterface::NetworkPerformance::network_utilization(Network
}
}
kstat_close(ctl);
*network_interfaces = ret;
return OS_OK;