netty_unix_socket free nettyClassName after using it
Motivation: netty_unix_socket attempts to use nettyClassName in an error message, but previously freed the memory. We should wait to free the memory until after we use it. Modifications: - Free nettyClassName after using it in snprintf Result: More useful error message.
This commit is contained in:
parent
804d8434dc
commit
fa8f967852
@ -1028,16 +1028,20 @@ jint netty_unix_socket_JNI_OnLoad(JNIEnv* env, const char* packagePrefix) {
|
|||||||
// Respect shading...
|
// Respect shading...
|
||||||
char parameters[1024] = {0};
|
char parameters[1024] = {0};
|
||||||
snprintf(parameters, sizeof(parameters), "(Ljava/lang/String;IIL%s;)V", nettyClassName);
|
snprintf(parameters, sizeof(parameters), "(Ljava/lang/String;IIL%s;)V", nettyClassName);
|
||||||
free(nettyClassName);
|
|
||||||
nettyClassName = NULL;
|
|
||||||
|
|
||||||
datagramSocketAddrMethodId = (*env)->GetMethodID(env, datagramSocketAddressClass, "<init>", parameters);
|
datagramSocketAddrMethodId = (*env)->GetMethodID(env, datagramSocketAddressClass, "<init>", parameters);
|
||||||
if (datagramSocketAddrMethodId == NULL) {
|
if (datagramSocketAddrMethodId == NULL) {
|
||||||
char msg[1024] = {0};
|
char msg[1024] = {0};
|
||||||
snprintf(msg, sizeof(msg), "failed to get method ID: %s.<init>(String, int, int, %s)", nettyClassName, nettyClassName);
|
snprintf(msg, sizeof(msg), "failed to get method ID: %s.<init>(String, int, int, %s)", nettyClassName, nettyClassName);
|
||||||
|
free(nettyClassName);
|
||||||
|
nettyClassName = NULL;
|
||||||
netty_unix_errors_throwRuntimeException(env, msg);
|
netty_unix_errors_throwRuntimeException(env, msg);
|
||||||
return JNI_ERR;
|
return JNI_ERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
free(nettyClassName);
|
||||||
|
nettyClassName = NULL;
|
||||||
|
|
||||||
jclass localInetSocketAddressClass = (*env)->FindClass(env, "java/net/InetSocketAddress");
|
jclass localInetSocketAddressClass = (*env)->FindClass(env, "java/net/InetSocketAddress");
|
||||||
if (localInetSocketAddressClass == NULL) {
|
if (localInetSocketAddressClass == NULL) {
|
||||||
// pending exception...
|
// pending exception...
|
||||||
|
Loading…
Reference in New Issue
Block a user