Fix memory leaks in system_server

unlink DeathRecipients in a whole bunch of places to avoid memory leaks
This commit is contained in:
Suchi Amalapurapu
2009-06-30 21:36:16 -07:00
parent c56096fe1f
commit fff2fda019
8 changed files with 41 additions and 6 deletions

View File

@@ -1875,7 +1875,9 @@ public class WifiService extends IWifiManager.Stub {
private WifiLock removeLock(IBinder binder) {
int index = findLockByBinder(binder);
if (index >= 0) {
return mList.remove(index);
WifiLock ret = mList.remove(index);
ret.unlinkDeathRecipient();
return ret;
} else {
return null;
}
@@ -1987,6 +1989,10 @@ public class WifiService extends IWifiManager.Stub {
binderDied();
}
}
void unlinkDeathRecipient() {
mBinder.unlinkToDeath(this, 0);
}
}
private class Multicaster extends DeathRecipient {
@@ -2054,7 +2060,10 @@ public class WifiService extends IWifiManager.Stub {
private void removeMulticasterLocked(int i, int uid)
{
mMulticasters.remove(i);
Multicaster removed = mMulticasters.remove(i);
if (removed != null) {
removed.unlinkDeathRecipient();
}
if (mMulticasters.size() == 0) {
WifiNative.startPacketFiltering();
}