From 58cc323c203bbbf80f5488845b2fec587401c5e3 Mon Sep 17 00:00:00 2001 From: Brad Lassey Date: Tue, 25 Nov 2014 13:04:07 -0500 Subject: [PATCH] bug 1104160 - crash in CPOWTimer::~CPOWTimer() r=billm --- js/ipc/CPOWTimer.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/js/ipc/CPOWTimer.cpp b/js/ipc/CPOWTimer.cpp index 3880c0a057de..ef2f752ed5c7 100644 --- a/js/ipc/CPOWTimer.cpp +++ b/js/ipc/CPOWTimer.cpp @@ -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; }