From 5ab22e88da8d79f9e19e8afffdd06206f42bab94 Mon Sep 17 00:00:00 2001 From: Roman Kennke Date: Thu, 3 Feb 2022 07:24:59 +0000 Subject: [PATCH] 8276990: Memory leak in invoker.c fillInvokeRequest() during JDI operations Reviewed-by: sspitsyn, cjplummer --- src/jdk.jdwp.agent/share/native/libjdwp/invoker.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/jdk.jdwp.agent/share/native/libjdwp/invoker.c b/src/jdk.jdwp.agent/share/native/libjdwp/invoker.c index 42e6741d467..2f6eb5f40a1 100644 --- a/src/jdk.jdwp.agent/share/native/libjdwp/invoker.c +++ b/src/jdk.jdwp.agent/share/native/libjdwp/invoker.c @@ -232,6 +232,7 @@ fillInvokeRequest(JNIEnv *env, InvokeRequest *request, /* * Squirrel away the method signature */ + JDI_ASSERT_MSG(request->methodSignature == NULL, "Request methodSignature not null"); error = methodSignature(method, NULL, &request->methodSignature, NULL); if (error != JVMTI_ERROR_NONE) { return error; @@ -775,6 +776,10 @@ invoker_completeInvokeRequest(jthread thread) */ deleteGlobalArgumentRefs(env, request); + JDI_ASSERT_MSG(request->methodSignature != NULL, "methodSignature is NULL"); + jvmtiDeallocate(request->methodSignature); + request->methodSignature = NULL; + /* From now on, do not access the request structure anymore * for this request id, because once we give up the invokerLock it may * be immediately reused by a new invoke request.