Bug 21643. Temporary hack to avoid leaking root wrapper when creating both, and root != wrapper. Note that the fix is 'sloppy', as there are flows-of-control that could potentially leak the NS_ADDREF(); however, since jband is rewriting this stuff RSN, and that stuff doesn't really ever fail too often, we'll let i slide. r=jband

This commit is contained in:
waterson%netscape.com 1999-12-17 00:02:58 +00:00
parent 35a89e2d11
commit 6baf6f2475

View File

@ -47,9 +47,7 @@ nsXPCWrappedNative::AddRef(void)
XPCContext* xpcc;
++mRefCnt;
NS_LOG_ADDREF(this, mRefCnt, "nsXPCWrappedNative", sizeof(*this));
if(1 == mRefCnt && mRoot != this)
NS_ADDREF(mRoot);
else if(2 == mRefCnt && nsnull != (xpcc = mClass->GetXPCContext()))
if(2 == mRefCnt && nsnull != (xpcc = mClass->GetXPCContext()))
JS_AddNamedRoot(xpcc->GetJSContext(), &mJSObj,
"nsXPCWrappedNative::mJSObj");
return mRefCnt;
@ -137,6 +135,8 @@ nsXPCWrappedNative::GetNewOrUsedWrapper(XPCContext* xpcc,
NS_ADDREF(wrapper);
goto return_wrapper;
}
NS_ADDREF(root);
}
// do a QI to make sure the object passed in really supports the
@ -232,6 +232,8 @@ nsXPCWrappedNative::GetNewOrUsedWrapper(XPCContext* xpcc,
wrapper->mNext = root->mNext;
root->mNext = wrapper;
NS_RELEASE(root);
return_wrapper:
if(rootObj)
NS_RELEASE(rootObj);
@ -284,6 +286,10 @@ nsXPCWrappedNative::nsXPCWrappedNative(nsISupports* aObj,
mDynamicScriptable = ds;
}
}
else
{
NS_ADDREF(mRoot);
}
mJSObj = aClass->NewInstanceJSObject(this);
if(mJSObj)