Skip to content

Commit

Permalink
fix bug 100260. xpconnect should not hold a weak reference to a class…
Browse files Browse the repository at this point in the history
…info object after the xpcwrappednativeproto that was holding a strong ref is destroyed. sr=jst, r=dbradley,markh.
  • Loading branch information
jband%netscape.com committed Sep 19, 2001
1 parent 06006e4 commit 229409f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
2 changes: 2 additions & 0 deletions js/src/xpconnect/src/xpcprivate.h
Original file line number Diff line number Diff line change
Expand Up @@ -1197,6 +1197,8 @@ class XPCNativeSet
XPCNativeInterface* newInterface,
PRUint16 position);

static void ClearCacheEntryForClassInfo(nsIClassInfo* classInfo);

inline JSBool FindMember(jsval name, XPCNativeMember** pMember,
PRUint16* pInterfaceIndex) const;

Expand Down
15 changes: 15 additions & 0 deletions js/src/xpconnect/src/xpcwrappednativeinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,21 @@ XPCNativeSet::GetNewOrUsed(XPCCallContext& ccx, nsIClassInfo* classInfo)
return set;
}

// static
void
XPCNativeSet::ClearCacheEntryForClassInfo(nsIClassInfo* classInfo)
{
XPCJSRuntime* rt;
ClassInfo2NativeSetMap* map;

if(nsnull != (rt = nsXPConnect::GetRuntime()) &&
nsnull != (map = rt->GetClassInfo2NativeSetMap()))
{ // scoped lock
XPCAutoLock lock(rt->GetMapLock());
map->Remove(classInfo);
}
}

// static
XPCNativeSet*
XPCNativeSet::GetNewOrUsed(XPCCallContext& ccx,
Expand Down
4 changes: 4 additions & 0 deletions js/src/xpconnect/src/xpcwrappednativeproto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ XPCWrappedNativeProto::~XPCWrappedNativeProto()
#ifdef DEBUG
PR_AtomicDecrement(&gDEBUG_LiveProtoCount);
#endif

// Note that our weak ref to mScope is not to be trusted at this point.

XPCNativeSet::ClearCacheEntryForClassInfo(mClassInfo);

delete mScriptableInfo;
}
Expand Down

0 comments on commit 229409f

Please sign in to comment.