From 67f7a12ec9708248244322379f57a53daaac10f0 Mon Sep 17 00:00:00 2001 From: "axel%pike.org" Date: Tue, 23 Oct 2001 07:34:27 +0000 Subject: [PATCH] bug 104042, fix leaks in main (ifstream) and UnionExpr::evaluate (adding a null check and some iteratorlove, too), r=sicking@bigfoot.com,peterv, sr=jst --- extensions/transformiix/source/main/transformiix.cpp | 2 ++ extensions/transformiix/source/xpath/UnionExpr.cpp | 11 ++++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/extensions/transformiix/source/main/transformiix.cpp b/extensions/transformiix/source/main/transformiix.cpp index 64002be497d4..f99ffc386791 100644 --- a/extensions/transformiix/source/main/transformiix.cpp +++ b/extensions/transformiix/source/main/transformiix.cpp @@ -138,6 +138,8 @@ int main(int argc, char** argv) { xsltProcessor.process(*xmlInput, *xmlFilename, xsltInput, *xsltFilename, *resultOutput); } resultFileStream.close(); + if (xmlInput != &cin) + delete xmlInput; txShutdown(); return 0; } //-- main diff --git a/extensions/transformiix/source/xpath/UnionExpr.cpp b/extensions/transformiix/source/xpath/UnionExpr.cpp index fefd5497824c..7b4095f53ca5 100644 --- a/extensions/transformiix/source/xpath/UnionExpr.cpp +++ b/extensions/transformiix/source/xpath/UnionExpr.cpp @@ -76,17 +76,18 @@ ExprResult* UnionExpr::evaluate(Node* context, ContextState* cs) { NodeSet* nodes = new NodeSet(); - ListIterator* iter = expressions.iterator(); + txListIterator iter(&expressions); - while (iter->hasNext()) { - Expr* expr = (Expr*)iter->next(); + while (iter.hasNext()) { + Expr* expr = (Expr*)iter.next(); ExprResult* exprResult = expr->evaluate(context, cs); - if (exprResult->getResultType() == ExprResult::NODESET) { + if (exprResult && + exprResult->getResultType() == ExprResult::NODESET) { ((NodeSet*)exprResult)->copyInto(*nodes); } + delete exprResult; } - delete iter; return nodes; } //-- evaluate