From 83d77b1cbb6d0179e9c130d51b7fada2e76e86d3 Mon Sep 17 00:00:00 2001 From: Justin King Date: Fri, 24 Feb 2023 15:49:00 +0000 Subject: [PATCH] 8303072: Memory leak in exeNullCallerTest.cpp Reviewed-by: dholmes --- test/jdk/jni/nullCaller/exeNullCallerTest.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/jdk/jni/nullCaller/exeNullCallerTest.cpp b/test/jdk/jni/nullCaller/exeNullCallerTest.cpp index 3d79befd941..260a1edb9b4 100644 --- a/test/jdk/jni/nullCaller/exeNullCallerTest.cpp +++ b/test/jdk/jni/nullCaller/exeNullCallerTest.cpp @@ -55,9 +55,11 @@ void getBundle(JNIEnv* env) { // msg = b.getString("message"); jstring msg = (jstring) m_ResourceBundle_getString.callReturnNotNull(b, env->NewStringUTF("message")); - if (std::string("Hello!") != env->GetStringUTFChars(msg, NULL)) { + const char* chars = env->GetStringUTFChars(msg, nullptr); + if (std::string("Hello!") != chars) { emitErrorMessageAndExit("Bundle didn't contain expected content"); } + env->ReleaseStringUTFChars(msg, chars); // ResourceBundle.clearCache() m_ResourceBundle_clearCache.callVoidMethod();