зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1295033 - Handle failure in nsXPCWrappedJS constructor r=mccr8
This commit is contained in:
Родитель
4fa8f3b74f
Коммит
b8a1fc66c2
|
@ -405,7 +405,9 @@ nsXPCWrappedJS::nsXPCWrappedJS(JSContext* cx,
|
|||
|
||||
if (IsRootWrapper()) {
|
||||
MOZ_ASSERT(!IsMultiCompartment(), "mNext is always nullptr here");
|
||||
xpc::CompartmentPrivate::Get(mJSObj)->GetWrappedJSMap()->Add(cx, this);
|
||||
if (!xpc::CompartmentPrivate::Get(mJSObj)->GetWrappedJSMap()->Add(cx, this)) {
|
||||
*rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
} else {
|
||||
NS_ADDREF(mRoot);
|
||||
mNext = mRoot->mNext;
|
||||
|
@ -416,8 +418,10 @@ nsXPCWrappedJS::nsXPCWrappedJS(JSContext* cx,
|
|||
// to migrate the chain to the global table on the XPCJSContext.
|
||||
if (mRoot->IsMultiCompartment()) {
|
||||
xpc::CompartmentPrivate::Get(mRoot->mJSObj)->GetWrappedJSMap()->Remove(mRoot);
|
||||
MOZ_RELEASE_ASSERT(nsXPConnect::GetContextInstance()->
|
||||
GetMultiCompartmentWrappedJSMap()->Add(cx, mRoot));
|
||||
auto destMap = nsXPConnect::GetContextInstance()->GetMultiCompartmentWrappedJSMap();
|
||||
if (!destMap->Add(cx, mRoot)) {
|
||||
*rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -554,7 +554,9 @@ nsXPCWrappedJSClass::DelegatedQueryInterface(nsXPCWrappedJS* self,
|
|||
nsresult rv = nsXPCWrappedJS::GetNewOrUsed(obj, aIID, getter_AddRefs(wrapper));
|
||||
|
||||
// Do the same thing we do for the "check for any existing wrapper" case above.
|
||||
*aInstancePtr = wrapper.forget().take()->GetXPTCStub();
|
||||
if (NS_SUCCEEDED(rv) && wrapper) {
|
||||
*aInstancePtr = wrapper.forget().take()->GetXPTCStub();
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче