Bug 1138770 - Make memory reporters that have been stashed for testing eligible for unregistration. r=mccr8.

--HG--
extra : rebase_source : 06dcca55a7a47e02d9b43289472c76b810663727
This commit is contained in:
Nicholas Nethercote 2015-03-02 18:55:42 -08:00
parent e4a0d35e15
commit 237067b8b5

View File

@ -1646,6 +1646,15 @@ nsMemoryReporterManager::UnregisterStrongReporter(nsIMemoryReporter* aReporter)
return NS_OK;
}
// We don't register new reporters when the block is in place, but we do
// unregister existing reporters. This is so we don't keep holding strong
// references that these reporters aren't expecting (which can keep them
// alive longer than intended).
if (mSavedStrongReporters && mSavedStrongReporters->Contains(aReporter)) {
mSavedStrongReporters->RemoveEntry(aReporter);
return NS_OK;
}
return NS_ERROR_FAILURE;
}
@ -1662,6 +1671,15 @@ nsMemoryReporterManager::UnregisterWeakReporter(nsIMemoryReporter* aReporter)
return NS_OK;
}
// We don't register new reporters when the block is in place, but we do
// unregister existing reporters. This is so we don't keep holding weak
// references that the old reporters aren't expecting (which can end up as
// dangling pointers that lead to use-after-frees).
if (mSavedWeakReporters && mSavedWeakReporters->Contains(aReporter)) {
mSavedWeakReporters->RemoveEntry(aReporter);
return NS_OK;
}
return NS_ERROR_FAILURE;
}