Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5a6ef737 authored by Dianne Hackborn's avatar Dianne Hackborn
Browse files

Fix issue #5595933: GREF leak due to race condition in...

...LoadedApk.ServiceDispatcher.connected , LoadedApk.forgetServiceDispatcher

Don't be stupid if we receive a new binding to a ServiceConnection after it
has already been unbound.

Change-Id: I85a49de97372bf9af55542a89031f0b7a2ac8fbb
parent 15843aa5
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -901,6 +901,7 @@ public final class LoadedApk {
        private RuntimeException mUnbindLocation;

        private boolean mDied;
        private boolean mForgotten;

        private static class ConnectionInfo {
            IBinder binder;
@@ -959,6 +960,7 @@ public final class LoadedApk {
                    ci.binder.unlinkToDeath(ci.deathMonitor, 0);
                }
                mActiveConnections.clear();
                mForgotten = true;
            }
        }

@@ -1020,6 +1022,11 @@ public final class LoadedApk {
            ServiceDispatcher.ConnectionInfo info;

            synchronized (this) {
                if (mForgotten) {
                    // We unbound before receiving the connection; ignore
                    // any connection received.
                    return;
                }
                old = mActiveConnections.get(name);
                if (old != null && old.binder == service) {
                    // Huh, already have this one.  Oh well!