Bug 940727 - Fix rooting hazard in DOMProxyHandler::GetAndClearExpandoObject() r=bholley

This commit is contained in:
Jon Coppeard 2013-11-20 15:37:30 +00:00
Родитель 4d65d888cb
Коммит dd160d493c
3 изменённых файлов: 21 добавлений и 1 удалений

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

@ -80,7 +80,10 @@ DOMProxyHandler::GetAndClearExpandoObject(JSObject* obj)
if (v.isObject()) {
js::SetProxyExtra(obj, JSPROXYSLOT_EXPANDO, UndefinedValue());
xpc::GetObjectScope(obj)->RemoveDOMExpandoObject(obj);
XPCWrappedNativeScope* scope = xpc::MaybeGetObjectScope(obj);
if (scope) {
scope->RemoveDOMExpandoObject(obj);
}
} else {
js::ExpandoAndGeneration* expandoAndGeneration =
static_cast<js::ExpandoAndGeneration*>(v.toPrivate());

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

@ -385,6 +385,20 @@ EnsureCompartmentPrivate(JSCompartment *c)
return priv;
}
XPCWrappedNativeScope*
MaybeGetObjectScope(JSObject *obj)
{
MOZ_ASSERT(obj);
JSCompartment *compartment = js::GetObjectCompartment(obj);
MOZ_ASSERT(compartment);
CompartmentPrivate *priv = GetCompartmentPrivate(compartment);
if (!priv)
return nullptr;
return priv->scope;
}
static bool
PrincipalImmuneToScriptPolicy(nsIPrincipal* aPrincipal)
{

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

@ -3786,6 +3786,9 @@ GetObjectScope(JSObject *obj)
return EnsureCompartmentPrivate(obj)->scope;
}
// This returns null if a scope doesn't already exist.
XPCWrappedNativeScope* MaybeGetObjectScope(JSObject *obj);
extern bool gDebugMode;
extern bool gDesiredDebugMode;