Fix local reference table overflow error problem. (#1178)

* Fix local reference table error problem.

* Modify the patch according to review comment.

* Fix a variable name.
This commit is contained in:
Joseph Pan
2018-04-03 20:01:27 +08:00
committed by James Chen
parent 4397330777
commit 036c13ea94
@@ -508,6 +508,7 @@ static bool JavaScriptJavaBridge_callStaticMethod(se::State& s)
{
int count = argc - 3;
jvalue* jargs = new jvalue[count];
std::vector<jobject> toReleaseObjects;
for (int i = 0; i < count; ++i)
{
int index = i + 3;
@@ -544,10 +545,15 @@ static bool JavaScriptJavaBridge_callStaticMethod(se::State& s)
std::string str;
seval_to_std_string(args[index], &str);
jargs[i].l = call.getEnv()->NewStringUTF(str.c_str());
toReleaseObjects.push_back(jargs[i].l);
break;
}
}
ok = call.executeWithArgs(jargs);
for (const auto& obj : toReleaseObjects)
{
call.getEnv()->DeleteLocalRef(obj);
}
if (jargs)
delete[] jargs;
int errorCode = call.getErrorCode();