changeset 51124:d2c720caa480

8208676: Missing NULL check and resource leak in NetworkPerformanceInterface::NetworkPerformance::network_utilization Reviewed-by: mgronlun, rehn
author rwestberg
date Mon, 06 Aug 2018 14:56:56 +0200
parents 945ba9278a27
children 2afc9aa349ed
files src/hotspot/os/linux/os_perf_linux.cpp src/hotspot/os/solaris/os_perf_solaris.cpp
diffstat 2 files changed, 3 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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;