Bug 273953 Crash during GC after leaving page in URL

patch by dbradley@gmail.com r=jst sr=brendan
This commit is contained in:
timeless%mozdev.org 2005-02-18 06:39:11 +00:00
parent 9c18978f3a
commit 3a6409e18e
3 changed files with 37 additions and 2 deletions

View File

@ -240,7 +240,7 @@ JSBool XPCIDispatchExtension::DefineProperty(XPCCallContext & ccx,
if(iface == nsnull)
return JS_FALSE;
XPCWrappedNativeTearOff* to =
wrapperToReflectInterfaceNames->FindTearOff(ccx, iface, JS_TRUE);
wrapperToReflectInterfaceNames->LocateTearOff(ccx, iface);
if(to == nsnull)
return JS_FALSE;
// get the JS Object for the tea

View File

@ -1892,6 +1892,8 @@ public:
inline JSBool HasInterfaceNoQI(XPCNativeInterface* aInterface);
inline JSBool HasInterfaceNoQI(const nsIID& iid);
XPCWrappedNativeTearOff* LocateTearOff(XPCCallContext& ccx,
XPCNativeInterface* aInterface);
XPCWrappedNativeTearOff* FindTearOff(XPCCallContext& ccx,
XPCNativeInterface* aInterface,
JSBool needJSObject = JS_FALSE,

View File

@ -1220,6 +1220,34 @@ XPCWrappedNative::ExtendSet(XPCCallContext& ccx, XPCNativeInterface* aInterface)
return JS_TRUE;
}
XPCWrappedNativeTearOff*
XPCWrappedNative::LocateTearOff(XPCCallContext& ccx,
XPCNativeInterface* aInterface)
{
XPCAutoLock al(GetLock()); // hold the lock throughout
for(
XPCWrappedNativeTearOffChunk* chunk = &mFirstChunk;
chunk != nsnull;
chunk = chunk->mNextChunk)
{
XPCWrappedNativeTearOff* tearOff = chunk->mTearOffs;
XPCWrappedNativeTearOff* const end = tearOff +
XPC_WRAPPED_NATIVE_TEAROFFS_PER_CHUNK;
for(
tearOff = chunk->mTearOffs;
tearOff < end;
tearOff++)
{
if(tearOff->GetInterface() == aInterface)
{
return tearOff;
}
}
}
return nsnull;
}
XPCWrappedNativeTearOff*
XPCWrappedNative::FindTearOff(XPCCallContext& ccx,
XPCNativeInterface* aInterface,
@ -1239,7 +1267,12 @@ XPCWrappedNative::FindTearOff(XPCCallContext& ccx,
lastChunk = chunk, chunk = chunk->mNextChunk)
{
to = chunk->mTearOffs;
for(int i = XPC_WRAPPED_NATIVE_TEAROFFS_PER_CHUNK; i > 0; i--, to++)
XPCWrappedNativeTearOff* const end = chunk->mTearOffs +
XPC_WRAPPED_NATIVE_TEAROFFS_PER_CHUNK;
for(
to = chunk->mTearOffs;
to < end;
to++)
{
if(to->GetInterface() == aInterface)
{