From 7baa88cc9d91d0e88c4da58559f9fdca1ae847ff Mon Sep 17 00:00:00 2001 From: rushiiMachine <33725716+rushiiMachine@users.noreply.github.com> Date: Wed, 28 Aug 2024 09:34:25 -0700 Subject: [PATCH] delete[] when failed to unbox --- core/src/main/cpp/invoke_constructor.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/core/src/main/cpp/invoke_constructor.cpp b/core/src/main/cpp/invoke_constructor.cpp index 7ac8272..a665571 100644 --- a/core/src/main/cpp/invoke_constructor.cpp +++ b/core/src/main/cpp/invoke_constructor.cpp @@ -135,10 +135,12 @@ bool InvokeConstructorWithArgs(JNIEnv *env, jobject instance, jobject constructo if (env->ExceptionOccurred()) return false; auto* unboxedArgs = new jvalue[argsCount]; - if (!unboxArgs(env, constructor, args, argsCount, unboxedArgs)) return false; + if (!unboxArgs(env, constructor, args, argsCount, unboxedArgs)) { + delete[] unboxedArgs; + return false; + } env->CallVoidMethodA(instance, constructorMethodId, unboxedArgs); - delete[] unboxedArgs; return !env->ExceptionOccurred(); }