diff --git a/xpcom/base/nsMemoryReporterManager.cpp b/xpcom/base/nsMemoryReporterManager.cpp index 0ce5a4c3cba..d65b782c508 100644 --- a/xpcom/base/nsMemoryReporterManager.cpp +++ b/xpcom/base/nsMemoryReporterManager.cpp @@ -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 reporter = aReporter; + nsCOMPtr mgr = do_GetService("@mozilla.org/memory-reporter-manager;1"); if (!mgr) { return NS_ERROR_FAILURE; } - return mgr->RegisterStrongReporter(aReporter); + return mgr->RegisterStrongReporter(reporter); } nsresult