Skip to content

Commit

Permalink
native: Specify valid pointer (with zero-len) to setsockopt
Browse files Browse the repository at this point in the history
... to keep the analyzer happy
  • Loading branch information
kohlschuetter committed Nov 25, 2024
1 parent c8f412e commit 97a16c2
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions junixsocket-native/src/main/c/socketoptions.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -393,5 +394,7 @@ JNIEXPORT void JNICALL Java_org_newsclub_net_unix_NativeUnixSocket_setSocketOpti
}

end:
free(valPtr);
if(valLen) {
free(valPtr);
}
}

0 comments on commit 97a16c2

Please sign in to comment.