changeset 52305:1b1bca603244

8209994: windows: Java_java_net_NetworkInterface_getAll misses releasing interface-list Reviewed-by: bpb, chegar, simonis
author mbaesken
date Tue, 28 Aug 2018 09:01:54 +0200
parents 67092c6be8e1
children de411d537aae
files src/java.base/windows/native/libnet/NetworkInterface.c src/java.base/windows/native/libnet/NetworkInterface_winXP.c
diffstat 2 files changed, 6 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.base/windows/native/libnet/NetworkInterface.c	Tue Aug 28 20:05:41 2018 -0700
+++ b/src/java.base/windows/native/libnet/NetworkInterface.c	Tue Aug 28 09:01:54 2018 +0200
@@ -826,7 +826,7 @@
     (JNIEnv *env, jclass cls)
 {
     int count;
-    netif *ifList, *curr;
+    netif *ifList = NULL, *curr;
     jobjectArray netIFArr;
     jint arr_index;
 
@@ -846,6 +846,7 @@
     /* allocate a NetworkInterface array */
     netIFArr = (*env)->NewObjectArray(env, count, cls, NULL);
     if (netIFArr == NULL) {
+        free_netif(ifList);
         return NULL;
     }
 
@@ -860,6 +861,7 @@
 
         netifObj = createNetworkInterface(env, curr, -1, NULL);
         if (netifObj == NULL) {
+            free_netif(ifList);
             return NULL;
         }
 
--- a/src/java.base/windows/native/libnet/NetworkInterface_winXP.c	Tue Aug 28 20:05:41 2018 -0700
+++ b/src/java.base/windows/native/libnet/NetworkInterface_winXP.c	Tue Aug 28 09:01:54 2018 +0200
@@ -784,7 +784,7 @@
     (JNIEnv *env, jclass cls)
 {
     int count;
-    netif *ifList, *curr;
+    netif *ifList = NULL, *curr;
     jobjectArray netIFArr;
     jint arr_index;
 
@@ -799,6 +799,7 @@
     /* allocate a NetworkInterface array */
     netIFArr = (*env)->NewObjectArray(env, count, cls, NULL);
     if (netIFArr == NULL) {
+        free_netif(ifList);
         return NULL;
     }
 
@@ -813,6 +814,7 @@
 
         netifObj = createNetworkInterfaceXP(env, curr);
         if (netifObj == NULL) {
+            free_netif(ifList);
             return NULL;
         }