Index: Source/core/xml/parser/XMLDocumentParser.cpp |
diff --git a/Source/core/xml/parser/XMLDocumentParser.cpp b/Source/core/xml/parser/XMLDocumentParser.cpp |
index 8ed8307aa3f33f9ab87f3c1c04a7d3fc444866af..96c1b79fad48f57326d44384fb8497958e825d9d 100644 |
--- a/Source/core/xml/parser/XMLDocumentParser.cpp |
+++ b/Source/core/xml/parser/XMLDocumentParser.cpp |
@@ -441,6 +441,12 @@ void XMLDocumentParser::finish() |
// makes sense to call any methods on DocumentParser once it's been stopped. |
// However, FrameLoader::stop calls DocumentParser::finish unconditionally. |
+ // flush may ending up executing arbitrary script, and possibly detach the parser. |
+ RefPtr<XMLDocumentParser> protect(this); |
+ flush(); |
+ if (isDetached()) |
+ return; |
+ |
if (m_parserPaused) |
m_finishCalled = true; |
else |