bug 1104160 - crash in CPOWTimer::~CPOWTimer() r=billm

This commit is contained in:
Brad Lassey 2014-11-25 13:04:07 -05:00
parent f03d959dfa
commit 58cc323c20

View File

@ -9,10 +9,19 @@
#include "xpcprivate.h"
#include "CPOWTimer.h"
CPOWTimer::~CPOWTimer() {
CPOWTimer::~CPOWTimer()
{
/* This is a best effort to find the compartment responsible for this CPOW call */
xpc::CompartmentPrivate* compartment = xpc::CompartmentPrivate::Get(js::GetObjectCompartment(mozilla::dom::GetIncumbentGlobal()
->GetGlobalJSObject()));
nsIGlobalObject *global = mozilla::dom::GetIncumbentGlobal();
if (!global)
return;
JSObject *obj = global->GetGlobalJSObject();
if (!obj)
return;
JSCompartment *compartment = js::GetObjectCompartment(obj);
xpc::CompartmentPrivate *compartmentPrivate = xpc::CompartmentPrivate::Get(compartment);
if (!compartmentPrivate)
return;
PRIntervalTime time = PR_IntervalNow() - startInterval;
compartment->CPOWTime += time;
compartmentPrivate->CPOWTime += time;
}