From d868da97802adde4d2879feff7ce1f121ab2d12d Mon Sep 17 00:00:00 2001 From: "pchen@netscape.com" Date: Wed, 4 Apr 2001 18:38:28 +0000 Subject: [PATCH] blocker bug 74728, r=pinkerton, Check for null mTokenAllocator before trying to free a token, for some reason unbeknowst to me, view source likes to create nsCParserNodes with a null allocator. Why this didn't bite us in the ass before is also beyond me. --- htmlparser/src/nsParserNode.cpp | 10 ++++++++-- parser/htmlparser/src/nsParserNode.cpp | 10 ++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/htmlparser/src/nsParserNode.cpp b/htmlparser/src/nsParserNode.cpp index f0221f1b4f1c..0f4a03cf1133 100644 --- a/htmlparser/src/nsParserNode.cpp +++ b/htmlparser/src/nsParserNode.cpp @@ -102,7 +102,10 @@ nsresult nsCParserNode::Init(CToken* aToken,PRInt32 aLineNumber,nsTokenAllocator if(mAttributes && (mAttributes->GetSize())) { CToken* theAttrToken=0; while((theAttrToken=NS_STATIC_CAST(CToken*,mAttributes->Pop()))) { - IF_FREE(theAttrToken, aTokenAllocator); + // nsViewSourceHTML.cpp:513 creates nsCParserNodes with a NULL token allocator + // need to check to see if mTokenAllocator is non-null + if(aTokenAllocator) + IF_FREE(theAttrToken, aTokenAllocator); } } mToken=aToken; @@ -343,7 +346,10 @@ nsresult nsCParserNode::ReleaseAll() { if(mAttributes) { CToken* theAttrToken=0; while((theAttrToken=NS_STATIC_CAST(CToken*,mAttributes->Pop()))) { - IF_FREE(theAttrToken, mTokenAllocator); + // nsViewSourceHTML.cpp:513 creates nsCParserNodes with a NULL token allocator + // need to check to see if mTokenAllocator is non-null + if(mTokenAllocator) + IF_FREE(theAttrToken, mTokenAllocator); } delete mAttributes; mAttributes=0; diff --git a/parser/htmlparser/src/nsParserNode.cpp b/parser/htmlparser/src/nsParserNode.cpp index f0221f1b4f1c..0f4a03cf1133 100644 --- a/parser/htmlparser/src/nsParserNode.cpp +++ b/parser/htmlparser/src/nsParserNode.cpp @@ -102,7 +102,10 @@ nsresult nsCParserNode::Init(CToken* aToken,PRInt32 aLineNumber,nsTokenAllocator if(mAttributes && (mAttributes->GetSize())) { CToken* theAttrToken=0; while((theAttrToken=NS_STATIC_CAST(CToken*,mAttributes->Pop()))) { - IF_FREE(theAttrToken, aTokenAllocator); + // nsViewSourceHTML.cpp:513 creates nsCParserNodes with a NULL token allocator + // need to check to see if mTokenAllocator is non-null + if(aTokenAllocator) + IF_FREE(theAttrToken, aTokenAllocator); } } mToken=aToken; @@ -343,7 +346,10 @@ nsresult nsCParserNode::ReleaseAll() { if(mAttributes) { CToken* theAttrToken=0; while((theAttrToken=NS_STATIC_CAST(CToken*,mAttributes->Pop()))) { - IF_FREE(theAttrToken, mTokenAllocator); + // nsViewSourceHTML.cpp:513 creates nsCParserNodes with a NULL token allocator + // need to check to see if mTokenAllocator is non-null + if(mTokenAllocator) + IF_FREE(theAttrToken, mTokenAllocator); } delete mAttributes; mAttributes=0;