Move the exception test

This commit is contained in:
ylecollen 2017-01-05 10:16:14 +01:00
parent 90c55806c0
commit eec8a50caf

View file

@ -62,9 +62,12 @@ bool setRandomInBuffer(JNIEnv *env, uint8_t **aBuffer2Ptr, size_t aRandomSize)
newObj = env->NewObject(cls, constructor); newObj = env->NewObject(cls, constructor);
jbyteArray tempByteArray = env->NewByteArray(bufferLen); jbyteArray tempByteArray = env->NewByteArray(bufferLen);
if (newObj && tempByteArray && !env->ExceptionOccurred()) if (newObj && tempByteArray)
{ {
env->CallVoidMethod(newObj, nextByteMethod, tempByteArray); env->CallVoidMethod(newObj, nextByteMethod, tempByteArray);
if (!env->ExceptionOccurred())
{
jbyte* buffer = env->GetByteArrayElements(tempByteArray, NULL); jbyte* buffer = env->GetByteArrayElements(tempByteArray, NULL);
if (buffer) if (buffer)
@ -80,6 +83,7 @@ bool setRandomInBuffer(JNIEnv *env, uint8_t **aBuffer2Ptr, size_t aRandomSize)
env->ReleaseByteArrayElements(tempByteArray, buffer, JNI_ABORT); env->ReleaseByteArrayElements(tempByteArray, buffer, JNI_ABORT);
} }
} }
}
if (tempByteArray) if (tempByteArray)
{ {