From 703ac9c1b5a7602f63f20b32ccf234c5e10de9d0 Mon Sep 17 00:00:00 2001 From: Waqar Ahmed Khan Date: Fri, 15 Nov 2024 14:46:24 -0800 Subject: [PATCH] Fix Segfault while Releasing Stream (#842) --- src/native/http2_stream_manager.c | 6 ++++-- src/native/http_request_response.c | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/native/http2_stream_manager.c b/src/native/http2_stream_manager.c index 231b4432a..b3765b1dd 100644 --- a/src/native/http2_stream_manager.c +++ b/src/native/http2_stream_manager.c @@ -82,8 +82,9 @@ static void s_on_stream_manager_shutdown_complete_callback(void *user_data) { } /* We're done with this wrapper, free it. */ + JavaVM *jvm = binding->jvm; s_destroy_manager_binding(binding, env); - aws_jni_release_thread_env(binding->jvm, env); + aws_jni_release_thread_env(jvm, env); /********** JNI ENV RELEASE **********/ } @@ -340,8 +341,9 @@ static void s_on_stream_acquired(struct aws_http_stream *stream, int error_code, } } AWS_FATAL_ASSERT(!aws_jni_check_and_clear_exception(env)); + JavaVM *jvm = callback_data->jvm; s_cleanup_sm_acquire_stream_callback_data(callback_data, env); - aws_jni_release_thread_env(callback_data->jvm, env); + aws_jni_release_thread_env(jvm, env); /********** JNI ENV RELEASE **********/ } diff --git a/src/native/http_request_response.c b/src/native/http_request_response.c index e478b55b4..1f56dbe44 100644 --- a/src/native/http_request_response.c +++ b/src/native/http_request_response.c @@ -306,8 +306,9 @@ void aws_java_http_stream_on_stream_destroy_fn(void *user_data) { return; } /* Native stream destroyed, release the binding. */ + JavaVM *jvm = binding->jvm; aws_http_stream_binding_release(env, binding); - aws_jni_release_thread_env(binding->jvm, env); + aws_jni_release_thread_env(jvm, env); /********** JNI ENV RELEASE **********/ }