Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit 546458d

Browse files
Merge pull request #6369 from livecodeali/bugfix-20992
[[ Bug 20992 ]] Use local frame for interface proxy creation
2 parents ff8299a + 8164c2e commit 546458d

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

docs/notes/bugfix-20992.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Fix crash when using several android native fields

libfoundation/src/foundation-java-private.cpp

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1441,10 +1441,15 @@ bool MCJavaCreateInterfaceProxy(MCNameRef p_class_name, MCTypeInfoRef p_signatur
14411441
if (MCHandlerTypeInfoGetParameterCount(p_signature) != 1)
14421442
return false;
14431443

1444+
s_env->PushLocalFrame(0);
1445+
14441446
MCValueRef t_handlers = *(static_cast<MCValueRef *>(p_args[0]));
1445-
1447+
14461448
if (!__MCJavaIsHandlerSuitableForListener(p_class_name, t_handlers))
1449+
{
1450+
s_env->PopLocalFrame(nullptr);
14471451
return false;
1452+
}
14481453

14491454
jclass t_inv_handler_class =
14501455
MCJavaPrivateFindClass(MCNAME("com.runrev.android.LCBInvocationHandler"));
@@ -1460,12 +1465,17 @@ bool MCJavaCreateInterfaceProxy(MCNameRef p_class_name, MCTypeInfoRef p_signatur
14601465
t_interface,
14611466
t_handler);
14621467

1468+
14631469
MCJavaObjectRef t_result_value;
1464-
if (!MCJavaObjectCreateNullable(t_proxy, t_result_value))
1465-
return false;
1470+
bool t_success = MCJavaObjectCreateNullable(t_proxy, t_result_value);
1471+
if (t_success)
1472+
{
1473+
*(static_cast<MCJavaObjectRef *>(r_result)) = t_result_value;
1474+
}
14661475

1467-
*(static_cast<MCJavaObjectRef *>(r_result)) = t_result_value;
1468-
return true;
1476+
s_env->PopLocalFrame(nullptr);
1477+
1478+
return t_success;
14691479
}
14701480

14711481
bool MCJavaPrivateCallJNIMethodOnEnv(void *p_env, MCNameRef p_class_name, void *p_method_id, int p_call_type, MCTypeInfoRef p_signature, void *r_return, void **p_args, uindex_t p_arg_count)

0 commit comments

Comments
 (0)