diff options
| author | 2020-01-28 10:08:18 +0100 | |
|---|---|---|
| committer | 2020-01-28 10:52:35 +0000 | |
| commit | 63a1446971b20f7f1cc96e34142b680f322eeba1 (patch) | |
| tree | 4c6faa41826c34c7ec6f57ed5c5fdc2b33c94ca5 | |
| parent | df29f8e5d59d9c8136eb2a2fd6c3bd605887c7ca (diff) | |
Don't leak local reference to BinderProxy.
The local reference created by javaObjectForIBinder() in the death
handling path is never freed, because it's not part of a regular JNI
call. Use a ScopedLocalRef<> to make sure it gets freed when we no
longer need it.
Bug: 148181449
Test: adb shell dumpsys activity binder-proxies shows low dead nodes
Change-Id: I031a46a310a06826bfadd77de7478b4342cf09ab
| -rw-r--r-- | core/jni/android_util_Binder.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/core/jni/android_util_Binder.cpp b/core/jni/android_util_Binder.cpp index fb8e633fec12..e77c25efb1d4 100644 --- a/core/jni/android_util_Binder.cpp +++ b/core/jni/android_util_Binder.cpp @@ -537,9 +537,10 @@ public: LOGDEATH("Receiving binderDied() on JavaDeathRecipient %p\n", this); if (mObject != NULL) { JNIEnv* env = javavm_to_jnienv(mVM); - jobject jBinderProxy = javaObjectForIBinder(env, who.promote()); + ScopedLocalRef<jobject> jBinderProxy(env, javaObjectForIBinder(env, who.promote())); env->CallStaticVoidMethod(gBinderProxyOffsets.mClass, - gBinderProxyOffsets.mSendDeathNotice, mObject, jBinderProxy); + gBinderProxyOffsets.mSendDeathNotice, mObject, + jBinderProxy.get()); if (env->ExceptionCheck()) { jthrowable excep = env->ExceptionOccurred(); report_exception(env, excep, |