From 97a16c2998493b93456e6e9c149ddbbb9c6b08ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Kohlschu=CC=88tter?= Date: Mon, 25 Nov 2024 14:29:13 +0100 Subject: [PATCH] native: Specify valid pointer (with zero-len) to setsockopt ... to keep the analyzer happy --- junixsocket-native/src/main/c/socketoptions.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/junixsocket-native/src/main/c/socketoptions.c b/junixsocket-native/src/main/c/socketoptions.c index f81e63bed..57da91779 100644 --- a/junixsocket-native/src/main/c/socketoptions.c +++ b/junixsocket-native/src/main/c/socketoptions.c @@ -357,10 +357,11 @@ JNIEXPORT void JNICALL Java_org_newsclub_net_unix_NativeUnixSocket_setSocketOpti return; } + long dummy = 0; void* valPtr; socklen_t valLen; if(value == NULL) { - valPtr = NULL; + valPtr = &dummy; valLen = 0; } else { jclass objClass = (*env)->GetObjectClass(env, value); @@ -393,5 +394,7 @@ JNIEXPORT void JNICALL Java_org_newsclub_net_unix_NativeUnixSocket_setSocketOpti } end: - free(valPtr); + if(valLen) { + free(valPtr); + } }