From 805ba192c4678e15087a5194014d4a6e9bb86b51 Mon Sep 17 00:00:00 2001 From: xylophone21 Date: Wed, 12 Jan 2022 21:28:29 +0800 Subject: [PATCH] fix memory issue in MediaInputMgr --- examples/tv-app/android/java/MediaInputManager.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/tv-app/android/java/MediaInputManager.cpp b/examples/tv-app/android/java/MediaInputManager.cpp index 8076ff100ef6f3..610a60dd3c749a 100644 --- a/examples/tv-app/android/java/MediaInputManager.cpp +++ b/examples/tv-app/android/java/MediaInputManager.cpp @@ -223,6 +223,7 @@ bool MediaInputManager::HandleHideInputStatus() bool MediaInputManager::HandleRenameInput(const uint8_t index, const chip::CharSpan & name) { + std::string inputname(name.data(), name.size()); jboolean ret = JNI_FALSE; JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); @@ -232,7 +233,7 @@ bool MediaInputManager::HandleRenameInput(const uint8_t index, const chip::CharS VerifyOrExit(env != NULL, ChipLogError(Zcl, "env null")); { - UtfString jniInputname(env, name.data()); + UtfString jniInputname(env, inputname.data()); env->ExceptionClear(); ret = env->CallBooleanMethod(mMediaInputManagerObject, mRenameInputMethod, static_cast(index), jniInputname.jniValue());