Bug 1987806 - Null check compartmentPrivate in FindSameOriginCompartment. a=RyanVM

We're hitting some null crashes in CompartmentOriginInfo::IsSameOrigin,
so maybe this is due to a null compartment private? We're iterating
over all compartments in a zone during SetNewDocument so maybe there's
something weird to stumble over.

Original Revision: https://phabricator.services.mozilla.com/D264335

Differential Revision: https://phabricator.services.mozilla.com/D266166
This commit is contained in:
Andrew McCreight
2025-09-26 04:13:04 +00:00
committed by rvandermeulen@mozilla.com
parent 5467b82c15
commit a8ffb60fd2

View File

@@ -1948,7 +1948,8 @@ static JS::CompartmentIterResult FindSameOriginCompartment(
} }
auto* compartmentPrivate = xpc::CompartmentPrivate::Get(aCompartment); auto* compartmentPrivate = xpc::CompartmentPrivate::Get(aCompartment);
if (!compartmentPrivate->CanShareCompartmentWith(data->principal)) { if (!compartmentPrivate ||
!compartmentPrivate->CanShareCompartmentWith(data->principal)) {
// Can't reuse this one, keep going. // Can't reuse this one, keep going.
return JS::CompartmentIterResult::KeepGoing; return JS::CompartmentIterResult::KeepGoing;
} }