From 76e336a948cdd36f05695a08ecd2a8f5fc5ddf62 Mon Sep 17 00:00:00 2001 From: Weijun Wang Date: Fri, 28 Feb 2014 08:40:27 +0800 Subject: [PATCH] 8035759: [parfait] JNI exception pending in jdk/src/windows/native/sun/security/krb5/NativeCreds.c Reviewed-by: valeriep --- .../native/sun/security/krb5/NativeCreds.c | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/jdk/src/windows/native/sun/security/krb5/NativeCreds.c b/jdk/src/windows/native/sun/security/krb5/NativeCreds.c index 7431333dc59..ab0ee036e6b 100644 --- a/jdk/src/windows/native/sun/security/krb5/NativeCreds.c +++ b/jdk/src/windows/native/sun/security/krb5/NativeCreds.c @@ -463,6 +463,10 @@ JNIEXPORT jobject JNICALL Java_sun_security_krb5_Credentials_acquireDefaultNativ 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 @@ jobject BuildPrincipal(JNIEnv *env, PKERB_EXTERNAL_NAME principalName, if (native_debug) { printf("LSA: Can't allocate String array for Principal\n"); } - LocalFree(realm); - return principal; + goto cleanup; } for (i=0; iNewString(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);