8036603: Check jdk/src/windows/native/java/lang/ProcessEnvironment_md.c for JNI pending exceptions
authormsheppar
Thu, 20 Mar 2014 21:03:43 +0000
changeset 23556 1726e34c34e8
parent 23555 679ad1863be3
child 23557 fdb248aa4e92
8036603: Check jdk/src/windows/native/java/lang/ProcessEnvironment_md.c for JNI pending exceptions Summary: added JNI call NULL return checks Reviewed-by: alanb, mchung
jdk/src/windows/native/java/lang/ProcessEnvironment_md.c
--- a/jdk/src/windows/native/java/lang/ProcessEnvironment_md.c	Thu Mar 20 13:41:17 2014 -0700
+++ b/jdk/src/windows/native/java/lang/ProcessEnvironment_md.c	Thu Mar 20 21:03:43 2014 +0000
@@ -35,9 +35,13 @@
     jmethodID String_init_ID;
     jbyteArray bytes;
     jbyte *blockA;
+    jclass string_class;
+
+    string_class = JNU_ClassString(env);
+    CHECK_NULL_RETURN(string_class, NULL);
 
     String_init_ID =
-        (*env)->GetMethodID(env, JNU_ClassString(env), "<init>", "([B)V");
+        (*env)->GetMethodID(env, string_class, "<init>", "([B)V");
     CHECK_NULL_RETURN(String_init_ID, NULL);
 
     blockA = (jbyte *) GetEnvironmentStringsA();
@@ -54,10 +58,13 @@
         while (blockA[i++])
             ;
 
-    if ((bytes = (*env)->NewByteArray(env, i)) == NULL) return NULL;
+    if ((bytes = (*env)->NewByteArray(env, i)) == NULL) {
+        FreeEnvironmentStringsA(blockA);
+        return NULL;
+    }
     (*env)->SetByteArrayRegion(env, bytes, 0, i, blockA);
     FreeEnvironmentStringsA(blockA);
-    return (*env)->NewObject(env, JNU_ClassString(env),
+    return (*env)->NewObject(env, string_class,
                              String_init_ID, bytes);
 }