changeset 9727:1c1743f8b263

8035759: [parfait] JNI exception pending in jdk/src/windows/native/sun/security/krb5/NativeCreds.c Reviewed-by: valeriep
author weijun
date Fri, 28 Feb 2014 08:40:27 +0800
parents c281bbd6ed87
children 790008bce87d
files src/windows/native/sun/security/krb5/NativeCreds.c
diffstat 1 files changed, 19 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/windows/native/sun/security/krb5/NativeCreds.c	Tue Jul 08 13:45:36 2014 -0700
+++ b/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);