Don't crash when ParseFragment() is called with an empty |aTagStack|. b=403877 r+sr=mrbkap a=jonas
authormats.palmgren@bredband.net
Fri, 16 Nov 2007 15:56:51 -0800
changeset 8100 2700d6caffb845461c3516abbe7983afa7841504
parent 8099 5c33ca3acf69fcaff222ade0035b5de76a8e94b5
child 8101 ba389d88e9afc921ec00da0defaf9dbac1aa80b4
push idunknown
push userunknown
push dateunknown
reviewersjonas
bugs403877
milestone1.9b2pre
Don't crash when ParseFragment() is called with an empty |aTagStack|. b=403877 r+sr=mrbkap a=jonas
parser/htmlparser/src/nsParser.cpp
--- a/parser/htmlparser/src/nsParser.cpp
+++ b/parser/htmlparser/src/nsParser.cpp
@@ -1448,17 +1448,17 @@ nsParser::ParseFragment(const nsAString&
   if (NS_FAILED(result)) {
     mFlags |= NS_PARSER_FLAG_OBSERVERS_ENABLED;
     return result;
   }
 
   nsCOMPtr<nsIFragmentContentSink> fragSink = do_QueryInterface(mSink);
   NS_ASSERTION(fragSink, "ParseFragment requires a fragment content sink");
 
-  if (!aXMLMode) {
+  if (!aXMLMode && theCount) {
     // First, we have to flush any tags that don't belong in the head if there
     // was no <body> in the context.
     // XXX This is extremely ugly. Maybe CNavDTD should have FlushMisplaced()?
     NS_ASSERTION(mParserContext, "Parsing didn't create a parser context?");
 
     CNavDTD* dtd = static_cast<CNavDTD*>
                               (static_cast<nsIDTD*>
                                           (mParserContext->mDTD));