Bug 1094953: Ensure that GetGlobalJSObject on the native global does not return null in nsXPCWrappedJSClass::DelegatedQueryInterface. r=bholley

This commit is contained in:
Bob Owen 2015-02-09 19:55:57 +00:00
Родитель 147b2557d7
Коммит 15061e2136
1 изменённых файлов: 5 добавлений и 0 удалений

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

@ -508,8 +508,13 @@ nsXPCWrappedJSClass::DelegatedQueryInterface(nsXPCWrappedJS* self,
// QI on an XPCWrappedJS can run script, so we need an AutoEntryScript.
// This is inherently Gecko-specific.
// We check both nativeGlobal and nativeGlobal->GetGlobalJSObject() even
// though we have derived nativeGlobal from the JS global, because we know
// there are cases where this can happen. See bug 1094953.
nsIGlobalObject* nativeGlobal =
NativeGlobal(js::GetGlobalForObjectCrossCompartment(self->GetJSObject()));
NS_ENSURE_TRUE(nativeGlobal, NS_ERROR_FAILURE);
NS_ENSURE_TRUE(nativeGlobal->GetGlobalJSObject(), NS_ERROR_FAILURE);
AutoEntryScript aes(nativeGlobal, /* aIsMainThread = */ true);
XPCCallContext ccx(NATIVE_CALLER, aes.cx());
if (!ccx.IsValid()) {