Bug 455633 - Protect against the weird Sandbox global object case when creating XPCNativeWrappers. r+sr=bzbarsky

This commit is contained in:
Blake Kaplan 2008-10-13 15:55:38 -07:00
parent 76e8be0e68
commit d9dc5056dc

View File

@ -778,9 +778,14 @@ MirrorWrappedNativeParent(JSContext *cx, XPCWrappedNative *wrapper,
XPCWrappedNative *parent_wrapper =
XPCWrappedNative::GetWrappedNativeOfJSObject(cx, wn_parent);
*result = XPCNativeWrapper::GetNewOrUsed(cx, parent_wrapper, nsnull);
if (!*result)
return JS_FALSE;
// parent_wrapper can be null if we're in a Components.utils.evalInSandbox
// scope. In that case, the best we can do is just use the
// non-native-wrapped sandbox global object for our parent.
if (parent_wrapper) {
*result = XPCNativeWrapper::GetNewOrUsed(cx, parent_wrapper, nsnull);
if (!*result)
return JS_FALSE;
}
}
return JS_TRUE;
}