From 8ced885bf514dfd0b9438feccdffb17cbf93f3b1 Mon Sep 17 00:00:00 2001 From: msheppar Date: Fri, 20 Jun 2014 20:17:11 +0100 Subject: [PATCH] 8036609: Check jdk/src/windows/native/java/lang/ProcessImpl_md.c for JNI pending exceptions Summary: added ExceptionCheck fater JNI calls Reviewed-by: chegar --- src/windows/native/java/lang/ProcessImpl_md.c | 40 ++++++++++--------- 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/src/windows/native/java/lang/ProcessImpl_md.c b/src/windows/native/java/lang/ProcessImpl_md.c index 86f403f86..922e5a501 100644 --- a/src/windows/native/java/lang/ProcessImpl_md.c +++ b/src/windows/native/java/lang/ProcessImpl_md.c @@ -359,24 +359,28 @@ Java_java_lang_ProcessImpl_create(JNIEnv *env, jclass ignored, const jchar *penvBlock = (envBlock != NULL) ? (*env)->GetStringChars(env, envBlock, NULL) : NULL; - const jchar *pdir = (dir != NULL) - ? (*env)->GetStringChars(env, dir, NULL) - : NULL; - jlong *handles = (*env)->GetLongArrayElements(env, stdHandles, NULL); - if (handles != NULL) { - ret = processCreate( - env, - pcmd, - penvBlock, - pdir, - handles, - redirectErrorStream); - (*env)->ReleaseLongArrayElements(env, stdHandles, handles, 0); + if (!(*env)->ExceptionCheck(env)) { + const jchar *pdir = (dir != NULL) + ? (*env)->GetStringChars(env, dir, NULL) + : NULL; + if (!(*env)->ExceptionCheck(env)) { + jlong *handles = (*env)->GetLongArrayElements(env, stdHandles, NULL); + if (handles != NULL) { + ret = processCreate( + env, + pcmd, + penvBlock, + pdir, + handles, + redirectErrorStream); + (*env)->ReleaseLongArrayElements(env, stdHandles, handles, 0); + } + if (pdir != NULL) + (*env)->ReleaseStringChars(env, dir, pdir); + } + if (penvBlock != NULL) + (*env)->ReleaseStringChars(env, envBlock, penvBlock); } - if (pdir != NULL) - (*env)->ReleaseStringChars(env, dir, pdir); - if (penvBlock != NULL) - (*env)->ReleaseStringChars(env, envBlock, penvBlock); (*env)->ReleaseStringChars(env, cmd, pcmd); } } @@ -448,7 +452,7 @@ Java_java_lang_ProcessImpl_isProcessAlive(JNIEnv *env, jclass ignored, jlong han JNIEXPORT jboolean JNICALL Java_java_lang_ProcessImpl_closeHandle(JNIEnv *env, jclass ignored, jlong handle) { - return CloseHandle((HANDLE) handle); + return (jboolean) CloseHandle((HANDLE) handle); } /** -- GitLab