8035759: [parfait] JNI exception pending in jdk/src/windows/native/sun/security/krb5/NativeCreds.c
authorweijun
Fri, 28 Feb 2014 08:40:27 +0800
changeset 23030 51178fbafe9c
parent 23029 8b6176ab95fb
child 23031 995cf5c2eb55
8035759: [parfait] JNI exception pending in jdk/src/windows/native/sun/security/krb5/NativeCreds.c Reviewed-by: valeriep
jdk/src/windows/native/sun/security/krb5/NativeCreds.c
--- a/jdk/src/windows/native/sun/security/krb5/NativeCreds.c	Thu Feb 27 09:43:28 2014 -0800
+++ b/jdk/src/windows/native/sun/security/krb5/NativeCreds.c	Fri Feb 28 08:40:27 2014 +0800
@@ -463,6 +463,10 @@
         netypes = (*env)->GetArrayLength(env, jetypes);
         etypes = (jint *) (*env)->GetIntArrayElements(env, jetypes, NULL);
 
+        if (etypes == NULL) {
+            break;
+        }
+
         // check TGT validity
         if (native_debug) {
             printf("LSA: TICKET SessionKey KeyType is %d\n", msticket->SessionKey.KeyType);
@@ -952,8 +956,7 @@
         if (native_debug) {
             printf("LSA: Can't allocate String array for Principal\n");
         }
-        LocalFree(realm);
-        return principal;
+        goto cleanup;
     }
 
     for (i=0; i<nameCount; i++) {
@@ -963,18 +966,32 @@
         // OK, got a Char array, so construct a String
         tempString = (*env)->NewString(env, (const jchar*)scanner->Buffer,
                             scanner->Length/sizeof(WCHAR));
+
+        if (tempString == NULL) {
+            goto cleanup;
+        }
+
         // Set the String into the StringArray
         (*env)->SetObjectArrayElement(env, stringArray, i, tempString);
 
+        if ((*env)->ExceptionCheck(env)) {
+            goto cleanup;
+        }
+
         // Do I have to worry about storage reclamation here?
     }
     // now set the realm in the principal
     realmLen = (ULONG)wcslen((PWCHAR)realm);
     realmStr = (*env)->NewString(env, (PWCHAR)realm, (USHORT)realmLen);
 
+    if (realmStr == NULL) {
+        goto cleanup;
+    }
+
     principal = (*env)->NewObject(env, principalNameClass,
                     principalNameConstructor, stringArray, realmStr);
 
+cleanup:
     // free local resources
     LocalFree(realm);