From 50690041b25592fa4a65274cb9e61ffda3939afb Mon Sep 17 00:00:00 2001 From: Jan de Mooij Date: Mon, 17 Sep 2018 17:13:05 +0000 Subject: [PATCH] Bug 1491533 - Null check CompartmentPrivate in SetCompartmentChangedDocumentDomain. r=bholley Differential Revision: https://phabricator.services.mozilla.com/D5998 --HG-- extra : moz-landing-system : lando --- js/xpconnect/src/XPCJSRuntime.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/js/xpconnect/src/XPCJSRuntime.cpp b/js/xpconnect/src/XPCJSRuntime.cpp index b44208788d22..676129d24d9a 100644 --- a/js/xpconnect/src/XPCJSRuntime.cpp +++ b/js/xpconnect/src/XPCJSRuntime.cpp @@ -599,9 +599,13 @@ CompartmentOriginInfo::IsSameOrigin(nsIPrincipal* aOther) const void SetCompartmentChangedDocumentDomain(JS::Compartment* compartment) { - CompartmentPrivate* priv = CompartmentPrivate::Get(compartment); - MOZ_ASSERT(priv); - priv->originInfo.SetChangedDocumentDomain(); + // Note: we call this for all compartments that contain realms with a + // particular principal. Not all of these compartments have a + // CompartmentPrivate (for instance the temporary compartment/realm + // created by the JS engine for off-thread parsing). + if (CompartmentPrivate* priv = CompartmentPrivate::Get(compartment)) { + priv->originInfo.SetChangedDocumentDomain(); + } } JSObject*