New fix for <rdar://problem/
3667701> crash in KHTMLPart::jScriptEnabled()
The tokenizer has buffers which mean parsing can continue even after loading is supposed to be stopped. If the loading process was aborted, the tokenizer should abort, too.
* khtml/html/htmltokenizer.cpp:
(khtml::HTMLTokenizer::HTMLTokenizer): Initialize loadStopped to false.
(khtml::HTMLTokenizer::write): Go ahead and bail out if loadStopped is true.
(khtml::HTMLTokenizer::processToken):
* khtml/html/htmltokenizer.h: Added loadStopped flag. Changed the view pointer from a standard pointer to a QGuardedPtr. This fixes the crash. Now the tokenizer's handle to the view will now automatically nil-out and never dangle.
* khtml/khtml_part.cpp:
(KHTMLPart::closeURL): Notify the tokenizer to stop parsing.
* khtml/xml/xml_tokenizer.cpp:
(khtml::XMLTokenizer::XMLTokenizer): Initialize loadStopped to false.
* khtml/xml/xml_tokenizer.h:
(khtml::Tokenizer::stopParsing): Added.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@8892
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2005-03-15 Kevin Decker <kdecker@apple.com>
+
+ Reviewed by Ken and Maciej.
+
+ New fix for <rdar://problem/3667701> crash in KHTMLPart::jScriptEnabled()
+
+ The tokenizer has buffers which mean parsing can continue even after loading is supposed to be stopped. If the loading process was aborted, the tokenizer should abort, too.
+
+ * khtml/html/htmltokenizer.cpp:
+ (khtml::HTMLTokenizer::HTMLTokenizer): Initialize loadStopped to false.
+ (khtml::HTMLTokenizer::write): Go ahead and bail out if loadStopped is true.
+ (khtml::HTMLTokenizer::processToken):
+ * khtml/html/htmltokenizer.h: Added loadStopped flag. Changed the view pointer from a standard pointer to a QGuardedPtr. This fixes the crash. Now the tokenizer's handle to the view will now automatically nil-out and never dangle.
+ * khtml/khtml_part.cpp:
+ (KHTMLPart::closeURL): Notify the tokenizer to stop parsing.
+ * khtml/xml/xml_tokenizer.cpp:
+ (khtml::XMLTokenizer::XMLTokenizer): Initialize loadStopped to false.
+ * khtml/xml/xml_tokenizer.h:
+ (khtml::Tokenizer::stopParsing): Added.
+
2005-03-14 David Harrison <harrison@apple.com>
Reviewed by Darin, Maciej.
attrNamePresent = false;
timerId = 0;
includesCommentsInDOM = includesComments;
+ loadStopped = false;
begin();
}
onHold = false;
timerId = 0;
includesCommentsInDOM = includesComments;
+ loadStopped = false;
begin();
}
if (!buffer)
return;
+
+ if (loadStopped)
+ return;
if ( ( m_executingScript && appendData ) || !cachedScript.isEmpty() ) {
// don't parse; we will do this later
}
kdDebug( 6036 ) << endl;
#endif
- // pass the token over to the parser, the parser DOES NOT delete the token
- parser->parseToken(&currToken);
-
+
+ if (!loadStopped) {
+ // pass the token over to the parser, the parser DOES NOT delete the token
+ parser->parseToken(&currToken);
+ }
+
currToken.reset();
if (jsProxy)
jsProxy->setEventHandlerLineno(0);
KCharsets *charsets;
KHTMLParser *parser;
- KHTMLView *view;
-
+ QGuardedPtr<KHTMLView> view;
+
#ifndef NDEBUG
bool inWrite;
#endif
bool KHTMLPart::closeURL()
-{
+{
+ if (d->m_doc && d->m_doc->tokenizer()) {
+ d->m_doc->tokenizer()->stopParsing();
+ }
+
if ( d->m_job )
{
KHTMLPageCache::self()->cancelEntry(d->m_cacheId);
* This file is part of the DOM implementation for KDE.
*
* Copyright (C) 2000 Peter Kelly (pmk@post.com)
- * Copyright (C) 2004 Apple Computer, Inc.
+ * Copyright (C) 2005 Apple Computer, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
{
if (m_doc)
m_doc->ref();
+
+ //FIXME: XMLTokenizer should use this in a fashion similiar to how
+ //HTMLTokenizer uses loadStopped, in the future.
+ loadStopped = false;
}
XMLTokenizer::~XMLTokenizer()
* This file is part of the DOM implementation for KDE.
*
* Copyright (C) 2000 Peter Kelly (pmk@post.com)
- * Copyright (C) 2004 Apple Computer, Inc.
+ * Copyright (C) 2005 Apple Computer, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
virtual void finish() = 0;
virtual void setOnHold(bool onHold) = 0;
virtual bool isWaitingForScripts() const = 0;
+ void stopParsing() { loadStopped = true; }
virtual void stopped() {};
virtual bool processingData() const { return false; }
+ // The tokenizer has buffers which mean parsing can continue even after
+ // loading is supposed to be stopped. If the loading process has stopped,
+ // so should we.
+ bool loadStopped;
+
#ifdef KHTML_XSLT
virtual void setTransformSource(DOM::DocumentImpl* doc) {};
#endif