From 7bd7ef3c846d5b45bcab3c57d7b3eb0aac66bad2 Mon Sep 17 00:00:00 2001 From: "mrbkap%gmail.com" Date: Wed, 1 Feb 2006 18:57:09 +0000 Subject: [PATCH] Don't create extra parser contexts once the parser has been terminated. Also make sure to clean up any extra parser contexts if they do get created. bug 323441, r=sicking sr=jst git-svn-id: svn://10.0.0.236/trunk@188682 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/parser/htmlparser/src/nsParser.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/mozilla/parser/htmlparser/src/nsParser.cpp b/mozilla/parser/htmlparser/src/nsParser.cpp index 68f86c6503e..f49b0e700cd 100644 --- a/mozilla/parser/htmlparser/src/nsParser.cpp +++ b/mozilla/parser/htmlparser/src/nsParser.cpp @@ -299,11 +299,17 @@ nsParser::~nsParser() } #endif -#ifdef DEBUG_mrbkap - NS_ASSERTION(!mParserContext || !mParserContext->mPrevContext, - "Leaking parsercontexts"); +#ifdef DEBUG + if (mParserContext && mParserContext->mPrevContext) { + NS_WARNING("Extra parser contexts still on the parser stack"); + } #endif - delete mParserContext; + + while (mParserContext) { + CParserContext *pc = mParserContext->mPrevContext; + delete mParserContext; + mParserContext = pc; + } if (mFlags & NS_PARSER_FLAG_PENDING_CONTINUE_EVENT) { NS_ASSERTION(mEventQueue != nsnull, "Event queue is null"); @@ -1343,6 +1349,11 @@ nsParser::Parse(const nsAString& aSourceBuffer, { nsresult result = NS_OK; + // Don't bother if we're never going to parse this. + if (mInternalState == NS_ERROR_HTMLPARSER_STOPPARSING) { + return result; + } + if (!aLastCall && aSourceBuffer.IsEmpty()) { // Nothing is being passed to the parser so return // immediately. mUnusedInput will get processed when