Bug 761422, part 3 - get security wrappers before changing maps. r=bholley

This commit is contained in:
Andrew McCreight 2012-07-30 21:01:59 -07:00
parent 40af3f379d
commit e9759cb6ad

View File

@ -1606,6 +1606,16 @@ XPCWrappedNative::ReparentWrapperIfFound(XPCCallContext& ccx,
JS_SetPrivate(flat, nullptr);
}
// Before proceeding, eagerly create any same-compartment security wrappers
// that the object might have. This forces us to take the 'WithWrapper' path
// while transplanting that handles this stuff correctly.
{
JSAutoEnterCompartment innerAC;
if (!innerAC.enter(ccx, aOldScope->GetGlobalJSObject()) ||
!wrapper->GetSameCompartmentSecurityWrapper(ccx))
return NS_ERROR_FAILURE;
}
{ // scoped lock
Native2WrappedNativeMap* oldMap = aOldScope->GetWrappedNativeMap();
Native2WrappedNativeMap* newMap = aNewScope->GetWrappedNativeMap();
@ -1641,16 +1651,6 @@ XPCWrappedNative::ReparentWrapperIfFound(XPCCallContext& ccx,
(void) newMap->Add(wrapper);
}
// Before proceeding, eagerly create any same-compartment security wrappers
// that the object might have. This forces us to take the 'WithWrapper' path
// while transplanting that handles this stuff correctly.
{
JSAutoEnterCompartment innerAC;
if (!innerAC.enter(ccx, aOldScope->GetGlobalJSObject()) ||
!wrapper->GetSameCompartmentSecurityWrapper(ccx))
return NS_ERROR_FAILURE;
}
JSObject *ww = wrapper->GetWrapper();
if (ww) {
JSObject *newwrapper;