Bug 1387058 - part1: Clear the static pointer when no more AudioStreams; r=jwwang

--HG--
extra : rebase_source : 24afc6aa73cdba9340d9678ea45a9aa9265daa75
This commit is contained in:
Chun-Min Chang 2017-08-04 14:20:48 +08:00
parent 45c3a7524e
commit bb2563e5f9

View File

@ -54,6 +54,10 @@ AudioNotificationReceiver::Unregister(AudioStream* aAudioStream)
MOZ_ASSERT(!sSubscribers->IsEmpty(), "No subscriber.");
sSubscribers->RemoveElement(aAudioStream);
if (sSubscribers->IsEmpty()) {
// Clear the static pointer here to prevent memory leak.
sSubscribers = nullptr;
}
ANR_LOG("The AudioStream: %p is unregistered successfully.", aAudioStream);
}