8208676: Missing NULL check and resource leak in NetworkPerformanceInterface::NetworkPerformance::network_utilization
authorrwestberg
Mon, 06 Aug 2018 14:56:56 +0200
changeset 51360 d2c720caa480
parent 51359 945ba9278a27
child 51361 2afc9aa349ed
8208676: Missing NULL check and resource leak in NetworkPerformanceInterface::NetworkPerformance::network_utilization Reviewed-by: mgronlun, rehn
src/hotspot/os/linux/os_perf_linux.cpp
src/hotspot/os/solaris/os_perf_solaris.cpp
--- a/src/hotspot/os/linux/os_perf_linux.cpp	Tue Aug 07 00:06:52 2018 -0700
+++ b/src/hotspot/os/linux/os_perf_linux.cpp	Mon Aug 06 14:56:56 2018 +0200
@@ -1107,7 +1107,7 @@
 
   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 @@
     ret = cur;
   }
 
+  freeifaddrs(addresses);
   *network_interfaces = ret;
 
   return OS_OK;
--- a/src/hotspot/os/solaris/os_perf_solaris.cpp	Tue Aug 07 00:06:52 2018 -0700
+++ b/src/hotspot/os/solaris/os_perf_solaris.cpp	Mon Aug 06 14:56:56 2018 +0200
@@ -816,6 +816,7 @@
     }
   }
 
+  kstat_close(ctl);
   *network_interfaces = ret;
 
   return OS_OK;