Bug 1122322 - Fix crash in worker memory reporter. r=bent, a=sledru
--- a/dom/workers/WorkerPrivate.cpp
+++ b/dom/workers/WorkerPrivate.cpp
@@ -2032,16 +2032,22 @@ public:
// Assumes that WorkerJSRuntimeStats will hold a reference to |path|, and
// not a copy, as TryToMapAddon() may later modify if.
nsCString path;
WorkerJSRuntimeStats rtStats(path);
{
MutexAutoLock lock(mMutex);
+ if (!mWorkerPrivate ||
+ !mWorkerPrivate->BlockAndCollectRuntimeStats(&rtStats, aAnonymize)) {
+ // Returning NS_OK here will effectively report 0 memory.
+ return NS_OK;
+ }
+
path.AppendLiteral("explicit/workers/workers(");
if (aAnonymize && !mWorkerPrivate->Domain().IsEmpty()) {
path.AppendLiteral("<anonymized-domain>)/worker(<anonymized-url>");
} else {
nsCString escapedDomain(mWorkerPrivate->Domain());
if (escapedDomain.IsEmpty()) {
escapedDomain += "chrome";
} else {
@@ -2051,22 +2057,16 @@ public:
path.AppendLiteral(")/worker(");
NS_ConvertUTF16toUTF8 escapedURL(mWorkerPrivate->ScriptURL());
escapedURL.ReplaceChar('/', '\\');
path.Append(escapedURL);
}
path.AppendPrintf(", 0x%p)/", static_cast<void*>(mWorkerPrivate));
TryToMapAddon(path);
-
- if (!mWorkerPrivate ||
- !mWorkerPrivate->BlockAndCollectRuntimeStats(&rtStats, aAnonymize)) {
- // Returning NS_OK here will effectively report 0 memory.
- return NS_OK;
- }
}
return xpc::ReportJSRuntimeExplicitTreeStats(rtStats, path,
aCallback, aClosure,
aAnonymize);
}
private: