changeset 9513:323b64a9dede

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
author msheppar
date Thu, 20 Mar 2014 21:03:43 +0000
parents 7b2c8d1c7aeb
children 4b4adb994191
files src/windows/native/java/lang/ProcessEnvironment_md.c
diffstat 1 files changed, 10 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/windows/native/java/lang/ProcessEnvironment_md.c	Thu Mar 20 13:41:17 2014 -0700
+++ b/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);
 }