Null-check the parent before attempting to outerize. rs=brendan

This commit is contained in:
Jeff Walden 2010-05-18 14:13:22 -07:00
parent 8c66dc0bc9
commit 0bd2ff1b53
2 changed files with 14 additions and 10 deletions

View File

@ -1318,11 +1318,13 @@ nsDOMWindowUtils::GetParent()
*rval = OBJECT_TO_JSVAL(parent);
// Outerize if necessary. Embrace the ugliness!
JSClass *clasp = JS_GetClass(cx, parent);
if (clasp->flags & JSCLASS_IS_EXTENDED) {
JSExtendedClass *xclasp = reinterpret_cast<JSExtendedClass *>(clasp);
if (JSObjectOp outerize = xclasp->outerObject)
*rval = OBJECT_TO_JSVAL(outerize(cx, parent));
if (parent) {
JSClass* clasp = JS_GET_CLASS(cx, parent);
if (clasp->flags & JSCLASS_IS_EXTENDED) {
JSExtendedClass* xclasp = reinterpret_cast<JSExtendedClass*>(clasp);
if (JSObjectOp outerize = xclasp->outerObject)
*rval = OBJECT_TO_JSVAL(outerize(cx, parent));
}
}
cc->SetReturnValueWasSet(PR_TRUE);

View File

@ -3676,11 +3676,13 @@ Parent(JSContext *cx, uintN argc, jsval *vp)
*vp = OBJECT_TO_JSVAL(parent);
/* Outerize if necessary. Embrace the ugliness! */
JSClass *clasp = JS_GET_CLASS(cx, parent);
if (clasp->flags & JSCLASS_IS_EXTENDED) {
JSExtendedClass *xclasp = reinterpret_cast<JSExtendedClass *>(clasp);
if (JSObjectOp outerize = xclasp->outerObject)
*vp = OBJECT_TO_JSVAL(outerize(cx, parent));
if (parent) {
JSClass *clasp = JS_GET_CLASS(cx, parent);
if (clasp->flags & JSCLASS_IS_EXTENDED) {
JSExtendedClass *xclasp = reinterpret_cast<JSExtendedClass *>(clasp);
if (JSObjectOp outerize = xclasp->outerObject)
*vp = OBJECT_TO_JSVAL(outerize(cx, parent));
}
}
return JS_TRUE;