Fix for bug 393329 (numerous xslt leaks visiting http://www.metacafe.com). r/sr/a=sicking.

This commit is contained in:
peterv@propagandism.org 2007-09-01 10:47:39 -07:00
parent e15b4acba1
commit 08658466bf
9 changed files with 60 additions and 9 deletions

View File

@ -41,6 +41,7 @@
#include "nscore.h"
#include "nsDebug.h"
#include "nsTraceRefcnt.h"
#include "prtypes.h"
#include "txDouble.h"
@ -49,11 +50,17 @@ class nsAString;
class txObject
{
public:
txObject()
{
MOZ_COUNT_CTOR(txObject);
}
/**
* Deletes this txObject
*/
virtual ~txObject()
{
MOZ_COUNT_DTOR(txObject);
}
};

View File

@ -70,6 +70,15 @@ class txXPathNode;
class Expr
{
public:
Expr()
{
MOZ_COUNT_CTOR(Expr);
}
virtual ~Expr()
{
MOZ_COUNT_DTOR(Expr);
}
/**
* Evaluates this Expr based on the given context node and processor state
* @param context the context node for evaluation of this Expr
@ -405,7 +414,15 @@ private:
class txNodeTest
{
public:
virtual ~txNodeTest() {}
txNodeTest()
{
MOZ_COUNT_CTOR(txNodeTest);
}
virtual ~txNodeTest()
{
MOZ_COUNT_DTOR(txNodeTest);
}
/*
* Virtual methods
* pretty much a txPattern, but not supposed to be used

View File

@ -72,10 +72,14 @@ public:
txAExprResult(txResultRecycler* aRecycler) : mRecycler(aRecycler)
{
}
virtual ~txAExprResult()
{
}
void AddRef()
{
++mRefCnt;
NS_LOG_ADDREF(this, mRefCnt, "txAExprResult", sizeof(*this));
}
void Release(); // Implemented in txResultRecycler.cpp

View File

@ -290,7 +290,9 @@ txResultRecycler::getNonSharedNodeSet(txNodeSet* aNodeSet, txNodeSet** aResult)
void
txAExprResult::Release()
{
if (--mRefCnt == 0) {
--mRefCnt;
NS_LOG_RELEASE(this, mRefCnt, "txAExprResult");
if (mRefCnt == 0) {
if (mRecycler) {
mRecycler->recycle(this);
}

View File

@ -59,10 +59,13 @@ public:
void AddRef()
{
++mRefCnt;
NS_LOG_ADDREF(this, mRefCnt, "txResultRecycler", sizeof(*this));
}
void Release()
{
if (--mRefCnt == 0) {
--mRefCnt;
NS_LOG_RELEASE(this, mRefCnt, "txResultRecycler");
if (mRefCnt == 0) {
mRefCnt = 1; //stabilize
delete this;
}

View File

@ -53,18 +53,19 @@ class txExecutionState;
class txInstruction : public TxObject
{
public:
txInstruction() : mNext(0)
txInstruction()
{
MOZ_COUNT_CTOR(txInstruction);
}
virtual ~txInstruction()
{
delete mNext;
MOZ_COUNT_DTOR(txInstruction);
}
virtual nsresult execute(txExecutionState& aEs) = 0;
txInstruction* mNext;
nsAutoPtr<txInstruction> mNext;
};
#define TX_DECL_TXINSTRUCTION \

View File

@ -236,6 +236,14 @@ protected:
class txIGlobalParameter
{
public:
txIGlobalParameter()
{
MOZ_COUNT_CTOR(txIGlobalParameter);
}
virtual ~txIGlobalParameter()
{
MOZ_COUNT_DTOR(txIGlobalParameter);
}
virtual nsresult getValue(txAExprResult** aValue) = 0;
};

View File

@ -72,13 +72,17 @@ txStylesheetCompiler::txStylesheetCompiler(const nsAString& aStylesheetURI,
nsrefcnt
txStylesheetCompiler::AddRef()
{
return ++mRefCnt;
++mRefCnt;
NS_LOG_ADDREF(this, mRefCnt, "txStylesheetCompiler", sizeof(*this));
return mRefCnt;
}
nsrefcnt
txStylesheetCompiler::Release()
{
if (--mRefCnt == 0) {
--mRefCnt;
NS_LOG_RELEASE(this, mRefCnt, "txStylesheetCompiler");
if (mRefCnt == 0) {
mRefCnt = 1; //stabilize
delete this;
return 0;
@ -764,7 +768,7 @@ txStylesheetCompilerState::addInstruction(nsAutoPtr<txInstruction> aInstruction)
txInstruction* newInstr = aInstruction;
*mNextInstrPtr = aInstruction.forget();
mNextInstrPtr = &newInstr->mNext;
mNextInstrPtr = newInstr->mNext.StartAssignment();
PRInt32 i, count = mGotoTargetPointers.Count();
for (i = 0; i < count; ++i) {

View File

@ -51,8 +51,13 @@ class Expr;
class txToplevelItem
{
public:
txToplevelItem()
{
MOZ_COUNT_CTOR(txToplevelItem);
}
virtual ~txToplevelItem()
{
MOZ_COUNT_DTOR(txToplevelItem);
}
enum type {