Skip to content

Commit

Permalink
Correctly delete global references when free SSL_CTX (java-native-acc…
Browse files Browse the repository at this point in the history
…ess#344)

Motivation:

We need to delete the previous created global references to ensure we not leak native memory

Modifications:

Use the correct function to delete the global references

Result:

No native memory leak
  • Loading branch information
normanmaurer authored Oct 12, 2021
1 parent fcd6f88 commit 5330133
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/main/c/netty_quic_boringssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -662,16 +662,16 @@ static void netty_boringssl_SSLContext_free(JNIEnv* env, jclass clazz, jlong ctx
}
jobject verifyCallbackRef = SSL_CTX_get_ex_data(ssl_ctx, verifyCallbackIdx);
if (verifyCallbackRef != NULL) {
(*env)->DeleteLocalRef(env, verifyCallbackRef);
(*env)->DeleteGlobalRef(env, verifyCallbackRef);
}
jobject certificateCallbackRef = SSL_CTX_get_ex_data(ssl_ctx, certificateCallbackIdx);
if (certificateCallbackRef != NULL) {
(*env)->DeleteLocalRef(env, certificateCallbackRef);
(*env)->DeleteGlobalRef(env, certificateCallbackRef);
}

jobject servernameCallbackRef = SSL_CTX_get_ex_data(ssl_ctx, servernameCallbackIdx);
if (servernameCallbackRef != NULL) {
(*env)->DeleteLocalRef(env, servernameCallbackRef);
(*env)->DeleteGlobalRef(env, servernameCallbackRef);
}

alpn_data* data = SSL_CTX_get_ex_data(ssl_ctx, alpn_data_idx);
Expand Down

0 comments on commit 5330133

Please sign in to comment.