src/java.base/unix/native/libnet/NetworkInterface.c
changeset 52157 7593b9b8e8f2
parent 51151 d6b131d2bc8b
child 52167 b1db57cfe6bd
--- a/src/java.base/unix/native/libnet/NetworkInterface.c	Wed Mar 28 08:42:45 2018 -0700
+++ b/src/java.base/unix/native/libnet/NetworkInterface.c	Fri Mar 30 08:37:31 2018 +0530
@@ -331,9 +331,16 @@
     netif *ifs, *curr;
     jobject obj = NULL;
     jboolean match = JNI_FALSE;
-    int family = (getInetAddress_family(env, iaObj) == java_net_InetAddress_IPv4) ?
-        AF_INET : AF_INET6;
+    int family = getInetAddress_family(env, iaObj);
     JNU_CHECK_EXCEPTION_RETURN(env, NULL);
+
+    if (family == java_net_InetAddress_IPv4) {
+        family = AF_INET;
+    } else if (family == java_net_InetAddress_IPv6) {
+        family = AF_INET6;
+    } else {
+        return NULL; // Invalid family
+    }
     ifs = enumInterfaces(env);
     if (ifs == NULL) {
         return NULL;