From ffc678b509c65a31445deda8c72fa182059c0ce6 Mon Sep 17 00:00:00 2001 From: "hyatt%netscape.com" Date: Wed, 24 Oct 2001 02:22:40 +0000 Subject: [PATCH] Fix leaks. r=dbaron, sr=hewitt --- content/shared/src/nsRuleNode.cpp | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/content/shared/src/nsRuleNode.cpp b/content/shared/src/nsRuleNode.cpp index 2f914dddd9db..458dca775169 100644 --- a/content/shared/src/nsRuleNode.cpp +++ b/content/shared/src/nsRuleNode.cpp @@ -407,15 +407,28 @@ nsRuleNode::nsRuleNode(nsIPresContext* aContext, nsIStyleRule* aRule, nsRuleNode mRootChildren = nsnull; } +PR_STATIC_CALLBACK(PRBool) DeleteRuleNodeChildren(nsHashKey* aKey, void* aData, void* aClosure) +{ + nsRuleNode* ruleNode = (nsRuleNode*)aData; + ruleNode->Destroy(); + return PR_TRUE; +} + nsRuleNode::~nsRuleNode() { MOZ_COUNT_DTOR(nsRuleNode); if (mStyleData.mResetData || mStyleData.mInheritedData) mStyleData.Destroy(0, mPresContext); - if (mParent && mChildren) - mChildren->Destroy(mPresContext); - else if (!mParent) - delete mRootChildren; + if (mParent) { + if (mChildren) + mChildren->Destroy(mPresContext); + } + else { + if (mRootChildren) { + mRootChildren->Enumerate(DeleteRuleNodeChildren, nsnull); + delete mRootChildren; + } + } } nsresult