You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Injector::GetNativeLogs in app/src/main/jni/Injector/Injector.cpp leaks one JNI local reference per log line.
ret = (jobjectArray)env->NewObjectArray((int)log_messages.size(), env->FindClass("java/lang/String"), env->NewStringUTF(""));
for (size_t i = 0; i < log_messages.size(); ++i) {
env->SetObjectArrayElement(ret, static_cast<jlong>(i), env->NewStringUTF(log_messages[i].c_str()));
}
NewStringUTF creates a local reference on every iteration. SetObjectArrayElement stores the string in the array and does not free that reference. The references stay until the native method returns.
The loop count is log_messages.size(), andthis function never clears the vector, so the count keeps growing. Android's local reference table holds 512 entries by default. A few hundred accumulated log lines can overflow it and abort the process.FixDo not delete ret; it is the return value.for (size_t i = 0; i < log_messages.size(); ++i) { jstring str = env->NewStringUTF(log_messages[i].c_str()); env->SetObjectArrayElement(ret, static_cast<jsize>(i), str); env->DeleteLocalRef(str);}
Activity