Bug 603845 - Protect ourselves against compartments that have null principals. r=gal

This commit is contained in:
Blake Kaplan 2010-10-13 11:37:25 -07:00
Родитель 2783a8459b
Коммит 0b81e11689
1 изменённых файлов: 10 добавлений и 2 удалений

Просмотреть файл

@ -60,9 +60,17 @@ GetCompartmentPrincipal(JSCompartment *compartment)
bool bool
AccessCheck::isSameOrigin(JSCompartment *a, JSCompartment *b) AccessCheck::isSameOrigin(JSCompartment *a, JSCompartment *b)
{ {
nsIPrincipal *aprin = GetCompartmentPrincipal(a);
nsIPrincipal *bprin = GetCompartmentPrincipal(b);
// If either a or b doesn't have principals, we don't have enough
// information to tell. Seeing as how this is Gecko, we are default-unsafe
// in this case.
if (!aprin || !bprin)
return true;
PRBool cond; PRBool cond;
return NS_SUCCEEDED(GetCompartmentPrincipal(a)->Equals(GetCompartmentPrincipal(b), &cond)) && return NS_SUCCEEDED(aprin->Equals(bprin, &cond)) && cond;
cond;
} }
bool bool