Followup fix for bug 307867 -- make sure to update our pointers to hashtable entries when the entries move. r=dveditz, sr=brendan, a=dveditz, branch181=dveditz

git-svn-id: svn://10.0.0.236/branches/MOZILLA_1_8_0_BRANCH@191140 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
bzbarsky%mit.edu
2006-02-24 05:13:51 +00:00
parent 57e648e95a
commit ba075c5d29
2 changed files with 38 additions and 2 deletions

View File

@@ -65,6 +65,7 @@ class nsIXPConnect;
class nsIStringBundle;
class nsSystemPrincipal;
struct ClassPolicy;
class DomainPolicy;
#if defined(DEBUG_mstoltz) || defined(DEBUG_caillon)
#define DEBUG_CAPS_HACKER
@@ -208,6 +209,10 @@ struct ClassPolicy : public PLDHashEntryHdr
{
char* key;
PLDHashTable* mPolicy;
// Note: the DomainPolicy owns us, so if if dies we will too. Hence no
// need to refcount it here (and in fact, we'd probably leak if we tried).
DomainPolicy* mDomainWeAreWildcardFor;
};
PR_STATIC_CALLBACK(void)
@@ -222,6 +227,13 @@ ClearClassPolicyEntry(PLDHashTable *table, PLDHashEntryHdr *entry)
PL_DHashTableDestroy(cp->mPolicy);
}
// Note: actual impl is going to be after the DomainPolicy class definition,
// since we need to access members of DomainPolicy in the impl
PR_STATIC_CALLBACK(void)
MoveClassPolicyEntry(PLDHashTable *table,
const PLDHashEntryHdr *from,
PLDHashEntryHdr *to);
PR_STATIC_CALLBACK(PRBool)
InitClassPolicyEntry(PLDHashTable *table,
PLDHashEntryHdr *entry,
@@ -241,6 +253,7 @@ InitClassPolicyEntry(PLDHashTable *table,
};
ClassPolicy* cp = (ClassPolicy*)entry;
cp->mDomainWeAreWildcardFor = nsnull;
cp->key = PL_strdup((const char*)key);
if (!cp->key)
return PR_FALSE;
@@ -279,7 +292,7 @@ public:
PL_DHashGetKeyStub,
PL_DHashStringKey,
PL_DHashMatchStringKey,
PL_DHashMoveEntryStub,
MoveClassPolicyEntry,
ClearClassPolicyEntry,
PL_DHashFinalizeStub,
InitClassPolicyEntry
@@ -336,6 +349,23 @@ private:
};
PR_STATIC_CALLBACK(void)
MoveClassPolicyEntry(PLDHashTable *table,
const PLDHashEntryHdr *from,
PLDHashEntryHdr *to)
{
memcpy(to, from, table->entrySize);
// Now update the mDefaultPolicy pointer that points to us, if any.
ClassPolicy* cp = NS_STATIC_CAST(ClassPolicy*, to);
if (cp->mDomainWeAreWildcardFor) {
NS_ASSERTION(cp->mDomainWeAreWildcardFor->mWildcardPolicy ==
NS_STATIC_CAST(const ClassPolicy*, from),
"Unexpected wildcard policy on mDomainWeAreWildcardFor");
cp->mDomainWeAreWildcardFor->mWildcardPolicy = cp;
}
}
/////////////////////////////
// nsScriptSecurityManager //
/////////////////////////////