aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMathieu Féry <[email protected]>2023-12-06 14:15:29 +0100
committerMathieu Féry <[email protected]>2023-12-06 14:27:13 +0100
commitd56cd13883c2af1f42906a5327c78b1a7c684012 (patch)
tree16da5fedc55bdb3de10e08512e0dbb56e4b3a554
parent2a48dd9009e5b0b17d78f016e149e4cb387539e6 (diff)
feat(callbackGenerator): Prevent NPE during call of java callback
NPE can occured when argument supplied by native api are compoundTypeWrapper but pointer are NULL
-rw-r--r--src/java/com/jogamp/gluegen/JavaCallbackEmitter.java3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/java/com/jogamp/gluegen/JavaCallbackEmitter.java b/src/java/com/jogamp/gluegen/JavaCallbackEmitter.java
index 247d3ac..8263372 100644
--- a/src/java/com/jogamp/gluegen/JavaCallbackEmitter.java
+++ b/src/java/com/jogamp/gluegen/JavaCallbackEmitter.java
@@ -878,7 +878,8 @@ public final class JavaCallbackEmitter {
final String baseArgName = info.cbFuncBinding.getArgumentName(i);
if( i != info.cbFuncUserParamIdx && currentJavaType.isCompoundTypeWrapper() ) {
final String cBaseArgName = CodeGenUtils.capitalizeString( baseArgName );
- unit.emit( "(*env)->CallStaticObjectMethod(env, cbClazzArg" + cBaseArgName + ", cbMethodArg" + cBaseArgName + ", " + baseArgName + "_jni)" );
+ final String jniArgName = baseArgName + "_jni";
+ unit.emit( jniArgName + " != NULL ? " + "(*env)->CallStaticObjectMethod(env, cbClazzArg" + cBaseArgName + ", cbMethodArg" + cBaseArgName + ", " + jniArgName + ") : NULL" );
} else {
unit.emit( baseArgName + "_jni" );
}