Bug 868741 - Fix a null-pointer crash in ProcessPriorityManager. r=bent

This crash would occur if a ParticularProcessPriorityManager observed a
wake-lock change after being ShutDown().
This commit is contained in:
Justin Lebar 2013-05-07 16:44:25 -04:00
parent 7e63d3b77e
commit 0ef86009b8

View File

@ -482,12 +482,25 @@ ParticularProcessPriorityManager::Init()
ParticularProcessPriorityManager::~ParticularProcessPriorityManager()
{
LOGP("Destroying ParticularProcessPriorityManager.");
UnregisterWakeLockObserver(this);
// Unregister our wake lock observer if ShutDown hasn't been called. (The
// wake lock observer takes raw refs, so we don't want to take chances here!)
// We don't call UnregisterWakeLockObserver unconditionally because the code
// will print a warning if it's called unnecessarily.
if (mContentParent) {
UnregisterWakeLockObserver(this);
}
}
/* virtual */ void
ParticularProcessPriorityManager::Notify(const WakeLockInformation& aInfo)
{
if (!mContentParent) {
// We've been shut down.
return;
}
bool* dest = nullptr;
if (aInfo.topic().EqualsLiteral("cpu")) {
dest = &mHoldsCPUWakeLock;
@ -805,6 +818,8 @@ ParticularProcessPriorityManager::ShutDown()
{
MOZ_ASSERT(mContentParent);
UnregisterWakeLockObserver(this);
if (mResetPriorityTimer) {
mResetPriorityTimer->Cancel();
mResetPriorityTimer = nullptr;