changeset 10463:6997c5d62334

8068028: JNI exception pending in jdk/src/solaris/native/java/net Summary: added null check to JNI function calls returns in Inet6AddressImpl.c net_util_md.c Reviewed-by: chegar, coffeys
author msheppar
date Wed, 21 Jan 2015 22:22:32 +0000
parents 713e7e20ca84
children c46daef6edb5 003f2c10f841
files src/solaris/native/java/net/Inet6AddressImpl.c src/solaris/native/java/net/NetworkInterface.c src/solaris/native/java/net/net_util_md.c
diffstat 3 files changed, 9 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/solaris/native/java/net/Inet6AddressImpl.c	Wed Jan 21 18:34:07 2015 +0000
+++ b/src/solaris/native/java/net/Inet6AddressImpl.c	Wed Jan 21 22:22:32 2015 +0000
@@ -196,6 +196,10 @@
     }
 
     name = (*env)->NewStringUTF(env, hostname);
+    if (name == NULL) {
+        freeifaddrs(ifa);
+        return NULL;
+    }
 
     /* Iterate over the interfaces, and total up the number of IPv4 and IPv6
      * addresses we have. Also keep a count of loopback addresses. We need to
--- a/src/solaris/native/java/net/NetworkInterface.c	Wed Jan 21 18:34:07 2015 +0000
+++ b/src/solaris/native/java/net/NetworkInterface.c	Wed Jan 21 22:22:32 2015 +0000
@@ -253,6 +253,7 @@
     if (name_utf == NULL) {
        if (!(*env)->ExceptionCheck(env))
            JNU_ThrowOutOfMemoryError(env, NULL);
+       freeif(ifs);
        return NULL;
     }
     /*
@@ -527,9 +528,9 @@
            JNU_ThrowOutOfMemoryError(env, NULL);
        return NULL;
     }
-    if ((sock =openSocketWithFallback(env, name_utf)) < 0) {
+    if ((sock = openSocketWithFallback(env, name_utf)) < 0) {
        (*env)->ReleaseStringUTFChars(env, name, name_utf);
-       return JNI_FALSE;
+       return NULL;
     }
 
 
--- a/src/solaris/native/java/net/net_util_md.c	Wed Jan 21 18:34:07 2015 +0000
+++ b/src/solaris/native/java/net/net_util_md.c	Wed Jan 21 22:22:32 2015 +0000
@@ -97,6 +97,7 @@
         CHECK_NULL(c);
         ni_defaultIndexID = (*env)->GetStaticFieldID(
             env, c, "defaultIndex", "I");
+        CHECK_NULL(ni_defaultIndexID);
         ni_class = c;
     }
     int defaultIndex;
@@ -119,6 +120,7 @@
         CHECK_NULL_RETURN(c, 0);
         ni_defaultIndexID = (*env)->GetStaticFieldID(env, c,
                                                      "defaultIndex", "I");
+        CHECK_NULL_RETURN(ni_defaultIndexID, 0);
         ni_class = c;
     }
     int defaultIndex = 0;