calling the Java method setCSDWrapper(String wrapper, String TMPDIR, String PATH) with null TMPDIR and PATH would cause a segfault because openconnect_set_csd_wrapper(vpninfo, name, value) requires a non-NULL value Signed-off-by: Daniel Lenski <dlenski at gmail.com> --- jni.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/jni.c b/jni.c index 4586136..c377a5c 100644 --- a/jni.c +++ b/jni.c @@ -879,8 +879,8 @@ JNIEXPORT void JNICALL Java_org_infradead_libopenconnect_LibOpenConnect_setCSDWr !get_cstring(ctx->jenv, jarg2, &arg2)) { openconnect_setup_csd(ctx->vpninfo, getuid(), 1, arg0); - openconnect_set_csd_environ(ctx->vpninfo, "TMPDIR", arg1); - openconnect_set_csd_environ(ctx->vpninfo, "PATH", arg2); + if (arg1) openconnect_set_csd_environ(ctx->vpninfo, "TMPDIR", arg1); + if (arg2) openconnect_set_csd_environ(ctx->vpninfo, "PATH", arg2); } release_cstring(ctx->jenv, jarg0, arg0); @@ -1405,7 +1405,7 @@ JNIEXPORT jobjectArray JNICALL Java_org_infradead_libopenconnect_LibOpenConnect_ { jmethodID mid; jobjectArray result; - struct libctx ctx = { .jenv = jenv, .jobj = NULL, .async_lock = NULL, vpninfo = -1, loglevel = -1 }; + struct libctx ctx = { .jenv = jenv, .jobj = NULL, .async_lock = NULL, .vpninfo = NULL, .cmd_fd = -1, .loglevel = -1 }; /* call C library */ struct oc_vpn_proto *protos; -- 2.7.4