From abde7e96c8ea8f36b48e99ed62029bf0e178a8fa Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 6 Dec 2019 10:16:00 +0100 Subject: Bug 1412: Fix commit a8c2de110a2254af137a3d99007cc77e3ecd8078 --- src/newt/native/NewtCommon.c | 13 +++++++++---- src/newt/native/NewtCommon.h | 4 ++-- 2 files changed, 11 insertions(+), 6 deletions(-) (limited to 'src/newt/native') diff --git a/src/newt/native/NewtCommon.c b/src/newt/native/NewtCommon.c index 313b1b9fe..b13190103 100644 --- a/src/newt/native/NewtCommon.c +++ b/src/newt/native/NewtCommon.c @@ -98,15 +98,18 @@ void NewtCommon_throwNewRuntimeException(JNIEnv *env, const char* msg, ...) } } -void NewtCommon_ExceptionCheck0(JNIEnv *env) +jboolean NewtCommon_ExceptionCheck0(JNIEnv *env) { if( (*env)->ExceptionCheck(env) ) { (*env)->ExceptionDescribe(env); (*env)->ExceptionClear(env); + return JNI_TRUE; + } else { + return JNI_FALSE; } } -void NewtCommon_ExceptionCheck1_throwNewRuntimeException(JNIEnv *env, const char* msg, ...) +jboolean NewtCommon_ExceptionCheck1_throwNewRuntimeException(JNIEnv *env, const char* msg, ...) { va_list ap; @@ -116,14 +119,16 @@ void NewtCommon_ExceptionCheck1_throwNewRuntimeException(JNIEnv *env, const char va_start(ap, msg); NewtCommon_throwNewRuntimeExceptionVA(env, msg, ap); va_end(ap); + return JNI_TRUE; + } else { + return JNI_FALSE; } } const char * NewtCommon_GetStaticStringMethod(JNIEnv *jniEnv, jclass clazz, jmethodID jGetStrID, char *dest, int destSize, const char *altText) { if(NULL != jniEnv && NULL != clazz && NULL != jGetStrID) { jstring jstr = (jstring) (*jniEnv)->CallStaticObjectMethod(jniEnv, clazz, jGetStrID); - NewtCommon_ExceptionCheck0(env); - if(NULL != jstr) { + if( !NewtCommon_ExceptionCheck0(jniEnv) && NULL != jstr) { const char * str = (*jniEnv)->GetStringUTFChars(jniEnv, jstr, NULL); if( NULL != str) { strncpy(dest, str, destSize-1); diff --git a/src/newt/native/NewtCommon.h b/src/newt/native/NewtCommon.h index 99f1440d3..07f3f69d7 100644 --- a/src/newt/native/NewtCommon.h +++ b/src/newt/native/NewtCommon.h @@ -39,8 +39,8 @@ jchar* NewtCommon_GetNullTerminatedStringChars(JNIEnv* env, jstring str); void NewtCommon_FatalError(JNIEnv *env, const char* msg, ...); void NewtCommon_throwNewRuntimeException(JNIEnv *env, const char* msg, ...); -void NewtCommon_ExceptionCheck0(JNIEnv *env); -void NewtCommon_ExceptionCheck1_throwNewRuntimeException(JNIEnv *env, const char* msg, ...); +jboolean NewtCommon_ExceptionCheck0(JNIEnv *env); +jboolean NewtCommon_ExceptionCheck1_throwNewRuntimeException(JNIEnv *env, const char* msg, ...); /** * -- cgit v1.2.3