Bug 849597 - Add more kung fu to nsParser. r=smaug, a=bajaj
authorHenri Sivonen <hsivonen@iki.fi>
Fri, 05 Apr 2013 15:36:16 +0300
changeset 118997 0c6effe4d05f3f60f7bfbc3ad1a67957c08088b0
parent 118996 fbbf1d226f4516c7e9026042fc87e2be5753265c
child 118998 72ec41538d37662052873673a56c6dc27f5a9f0e
push id642
push userryanvm@gmail.com
push dateTue, 09 Apr 2013 13:46:51 +0000
reviewerssmaug, bajaj
bugs849597
milestone18.0
Bug 849597 - Add more kung fu to nsParser. r=smaug, a=bajaj
parser/htmlparser/src/nsParser.cpp
--- a/parser/htmlparser/src/nsParser.cpp
+++ b/parser/htmlparser/src/nsParser.cpp
@@ -1102,16 +1102,17 @@ nsParser::ContinueInterruptedParsing()
   }
 
   // If the stream has already finished, there's a good chance
   // that we might start closing things down when the parser
   // is reenabled. To make sure that we're not deleted across
   // the reenabling process, hold a reference to ourselves.
   nsresult result=NS_OK;
   nsCOMPtr<nsIParser> kungFuDeathGrip(this);
+  nsCOMPtr<nsIContentSink> sinkDeathGrip(mSink);
 
 #ifdef DEBUG
   if (!(mFlags & NS_PARSER_FLAG_PARSER_ENABLED)) {
     NS_WARNING("Don't call ContinueInterruptedParsing on a blocked parser.");
   }
 #endif
 
   bool isFinalChunk = mParserContext &&
@@ -2113,16 +2114,18 @@ nsParser::OnDataAvailable(nsIRequest *re
     if (NS_FAILED(rv)) {
       return rv;
     }
 
     // Don't bother to start parsing until we've seen some
     // non-whitespace data
     if (IsOkToProcessNetworkData() &&
         theContext->mScanner->FirstNonWhitespacePosition() >= 0) {
+      nsCOMPtr<nsIParser> kungFuDeathGrip(this);
+      nsCOMPtr<nsIContentSink> sinkDeathGrip(mSink);
       mProcessingNetworkData = true;
       if (mSink) {
         mSink->WillParse();
       }
       rv = ResumeParse();
       mProcessingNetworkData = false;
     }
   } else {