From d56cd13883c2af1f42906a5327c78b1a7c684012 Mon Sep 17 00:00:00 2001 From: Mathieu Féry Date: Wed, 6 Dec 2023 14:15:29 +0100 Subject: feat(callbackGenerator): Prevent NPE during call of java callback NPE can occured when argument supplied by native api are compoundTypeWrapper but pointer are NULL --- src/java/com/jogamp/gluegen/JavaCallbackEmitter.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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" ); } -- cgit v1.2.3