From 263a106c814beda0978e44c9903b8beac34b30f7 Mon Sep 17 00:00:00 2001 From: Paul Praet <3198728+praetp@users.noreply.github.com> Date: Tue, 20 Aug 2024 14:14:18 +0200 Subject: [PATCH] Fix tls_ctx memleak in s3 client creation Reproduction scenario: ``` try(var tlsc = new TlsContext(); var c = new S3Client(new S3ClientOptions() .withRegion("eu-west-1") .withClientBootstrap(ClientBootstrap.getOrCreateStaticDefault()) .withTlsContext(tlsc) )) { } ``` --> this code will quickly go OOM without the fix in this commit --- src/native/s3_client.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/native/s3_client.c b/src/native/s3_client.c index 09d516f53..6d19db0bf 100644 --- a/src/native/s3_client.c +++ b/src/native/s3_client.c @@ -521,7 +521,9 @@ JNIEXPORT jlong JNICALL Java_software_amazon_awssdk_crt_s3_S3Client_s3ClientNew( env, &proxy_options, jni_proxy_host, jni_proxy_authorization_username, jni_proxy_authorization_password); aws_mem_release(aws_jni_get_allocator(), s3_tcp_keep_alive_options); - + if (tls_options) { + aws_tls_connection_options_clean_up(tls_options); + } return (jlong)client; }