From f9719054c5f974cef06049912fa34ce98bb5ac5e Mon Sep 17 00:00:00 2001 From: "akkana%netscape.com" Date: Mon, 13 Sep 1999 20:26:14 +0000 Subject: [PATCH] Fix memory leak 13641: don't allocate a new CAttributeToken unless we're going to pass it to AddAttribute --- htmlparser/src/nsXIFDTD.cpp | 15 +++++++++------ parser/htmlparser/src/nsXIFDTD.cpp | 15 +++++++++------ 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/htmlparser/src/nsXIFDTD.cpp b/htmlparser/src/nsXIFDTD.cpp index 015ec2ae96b9..f271e13c595d 100644 --- a/htmlparser/src/nsXIFDTD.cpp +++ b/htmlparser/src/nsXIFDTD.cpp @@ -624,15 +624,18 @@ nsresult nsXIFDTD::HandleTextToken(CToken* aToken) { void nsXIFDTD::AddAttribute(nsIParserNode& aNode) { - nsString key; - nsString value; - PRBool hasValue; - - hasValue = GetAttributePair(aNode,key,value); - CAttributeToken* attribute = new CAttributeToken(key,value); nsIParserNode* top = PeekNode(); if (top != nsnull) + { + nsString key; + nsString value; + PRBool hasValue; + + hasValue = GetAttributePair(aNode,key,value); + // XXX should we still be calling AddAttribute if hasValue is false? + CAttributeToken* attribute = new CAttributeToken(key,value); ((nsCParserNode*)top)->AddAttribute(attribute); + } } diff --git a/parser/htmlparser/src/nsXIFDTD.cpp b/parser/htmlparser/src/nsXIFDTD.cpp index 015ec2ae96b9..f271e13c595d 100644 --- a/parser/htmlparser/src/nsXIFDTD.cpp +++ b/parser/htmlparser/src/nsXIFDTD.cpp @@ -624,15 +624,18 @@ nsresult nsXIFDTD::HandleTextToken(CToken* aToken) { void nsXIFDTD::AddAttribute(nsIParserNode& aNode) { - nsString key; - nsString value; - PRBool hasValue; - - hasValue = GetAttributePair(aNode,key,value); - CAttributeToken* attribute = new CAttributeToken(key,value); nsIParserNode* top = PeekNode(); if (top != nsnull) + { + nsString key; + nsString value; + PRBool hasValue; + + hasValue = GetAttributePair(aNode,key,value); + // XXX should we still be calling AddAttribute if hasValue is false? + CAttributeToken* attribute = new CAttributeToken(key,value); ((nsCParserNode*)top)->AddAttribute(attribute); + } }