Bug 982072 - Don't leak the argument passed to RegisterStrongMemoryReporter if we fail to get the service; r=froydnj

This commit is contained in:
Ehsan Akhgari 2014-03-11 14:15:27 -04:00
parent 1dd06e308b
commit 7e1e6e5ff9

View File

@ -1741,12 +1741,16 @@ namespace mozilla {
nsresult
RegisterStrongMemoryReporter(nsIMemoryReporter* aReporter)
{
// Hold a strong reference to the argument to make sure it gets released if
// we return early below.
nsCOMPtr<nsIMemoryReporter> reporter = aReporter;
nsCOMPtr<nsIMemoryReporterManager> mgr =
do_GetService("@mozilla.org/memory-reporter-manager;1");
if (!mgr) {
return NS_ERROR_FAILURE;
}
return mgr->RegisterStrongReporter(aReporter);
return mgr->RegisterStrongReporter(reporter);
}
nsresult