Don't call DidBuildModel twice if Terminate is called twice since consumers aren't expecting it. bug 378982, r+sr=bzbarsky
authormrbkap@gmail.com
Mon, 21 May 2007 11:09:54 -0700
changeset 1678 3bc31639db77e099e2da7d06a833fa349536b00e
parent 1677 de7d620f849955761c3c0a4e9f5da06a7f62d952
child 1679 45ce323f24645806ac29c7cad822999aeaf4d9e5
push idunknown
push userunknown
push dateunknown
bugs378982
milestone1.9a5pre
Don't call DidBuildModel twice if Terminate is called twice since consumers aren't expecting it. bug 378982, r+sr=bzbarsky
parser/htmlparser/src/nsParser.cpp
--- a/parser/htmlparser/src/nsParser.cpp
+++ b/parser/htmlparser/src/nsParser.cpp
@@ -1033,16 +1033,22 @@ nsParser::GetRootContextKey()
 /**
  *  Call this when you want to *force* the parser to terminate the
  *  parsing process altogether. This is binary -- so once you terminate
  *  you can't resume without restarting altogether.
  */
 NS_IMETHODIMP
 nsParser::Terminate(void)
 {
+  // We should only call DidBuildModel once, so don't do anything if this is
+  // the second time that Terminate has been called.
+  if (mInternalState == NS_ERROR_HTMLPARSER_STOPPARSING) {
+    return NS_OK;
+  }
+
   nsresult result = NS_OK;
   // XXX - [ until we figure out a way to break parser-sink circularity ]
   // Hack - Hold a reference until we are completely done...
   nsCOMPtr<nsIParser> kungFuDeathGrip(this);
   mInternalState = result = NS_ERROR_HTMLPARSER_STOPPARSING;
 
   // CancelParsingEvents must be called to avoid leaking the nsParser object
   // @see bug 108049