8209994: windows: Java_java_net_NetworkInterface_getAll misses releasing interface-list
authormbaesken
Tue, 28 Aug 2018 09:01:54 +0200
changeset 51562 1b1bca603244
parent 51561 67092c6be8e1
child 51563 de411d537aae
8209994: windows: Java_java_net_NetworkInterface_getAll misses releasing interface-list Reviewed-by: bpb, chegar, simonis
src/java.base/windows/native/libnet/NetworkInterface.c
src/java.base/windows/native/libnet/NetworkInterface_winXP.c
--- 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;
         }