From 533013331ff20ee87de4e583de82ef435c7a7b0f Mon Sep 17 00:00:00 2001 From: Norman Maurer Date: Tue, 12 Oct 2021 15:28:06 +0200 Subject: [PATCH] Correctly delete global references when free SSL_CTX (#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 --- src/main/c/netty_quic_boringssl.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/c/netty_quic_boringssl.c b/src/main/c/netty_quic_boringssl.c index 0df681c8b..37592ce48 100644 --- a/src/main/c/netty_quic_boringssl.c +++ b/src/main/c/netty_quic_boringssl.c @@ -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);