From 23b5ae184f650574c57b198a1fc1340252427b9c Mon Sep 17 00:00:00 2001 From: Bobby Holley Date: Mon, 3 Jun 2013 11:27:41 -0700 Subject: [PATCH] Bug 877862 - Propagate exceptions from PrepareForWrapping. r=mrbkap --- js/xpconnect/wrappers/WrapperFactory.cpp | 38 ++++++++++++------------ 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/js/xpconnect/wrappers/WrapperFactory.cpp b/js/xpconnect/wrappers/WrapperFactory.cpp index 83a84d8c41a..87c982b2026 100644 --- a/js/xpconnect/wrappers/WrapperFactory.cpp +++ b/js/xpconnect/wrappers/WrapperFactory.cpp @@ -297,26 +297,26 @@ WrapperFactory::PrepareForWrapping(JSContext *cx, HandleObject scope, nsXPConnect::XPConnect()->WrapNativeToJSVal(cx, wrapScope, wn->Native(), nullptr, &NS_GET_IID(nsISupports), false, v.address(), getter_AddRefs(holder)); - if (NS_SUCCEEDED(rv)) { - obj = JSVAL_TO_OBJECT(v); - NS_ASSERTION(IS_WN_WRAPPER(obj), "bad object"); + NS_ENSURE_SUCCESS(rv, nullptr); - // Because the underlying native didn't have a PreCreate hook, we had - // to a new (or possibly pre-existing) XPCWN in our compartment. - // This could be a problem for chrome code that passes XPCOM objects - // across compartments, because the effects of QI would disappear across - // compartments. - // - // So whenever we pull an XPCWN across compartments in this manner, we - // give the destination object the union of the two native sets. We try - // to do this cleverly in the common case to avoid too much overhead. - XPCWrappedNative *newwn = static_cast(xpc_GetJSPrivate(obj)); - XPCNativeSet *unionSet = XPCNativeSet::GetNewOrUsed(ccx, newwn->GetSet(), - wn->GetSet(), false); - if (!unionSet) - return nullptr; - newwn->SetSet(unionSet); - } + obj = JSVAL_TO_OBJECT(v); + NS_ASSERTION(IS_WN_WRAPPER(obj), "bad object"); + + // Because the underlying native didn't have a PreCreate hook, we had + // to a new (or possibly pre-existing) XPCWN in our compartment. + // This could be a problem for chrome code that passes XPCOM objects + // across compartments, because the effects of QI would disappear across + // compartments. + // + // So whenever we pull an XPCWN across compartments in this manner, we + // give the destination object the union of the two native sets. We try + // to do this cleverly in the common case to avoid too much overhead. + XPCWrappedNative *newwn = static_cast(xpc_GetJSPrivate(obj)); + XPCNativeSet *unionSet = XPCNativeSet::GetNewOrUsed(ccx, newwn->GetSet(), + wn->GetSet(), false); + if (!unionSet) + return nullptr; + newwn->SetSet(unionSet); return DoubleWrap(cx, obj, flags); }