+2004-09-23 John Sullivan <sullivan@apple.com>
+
+ Reviewed by Ken.
+
+ - fixed <rdar://problem/3527840> reproducible crash at johnbrown.v32.qikker.com
+ (nil-deref in NodeImpl::dispatchEvent)
+
+ * khtml/xml/dom_nodeimpl.cpp:
+ (NodeImpl::dispatchEvent):
+ guard against document or document->document() being nil
+
2004-09-23 Darin Adler <darin@apple.com>
Reviewed by Ken.
evt->setTarget(this);
- KHTMLPart *part = document->document()->part();
-
- // Since event handling code could cause this object to be deleted, grab a reference to the view now
- KHTMLView *view = document->document()->view();
- if (view)
- view->ref();
+ // We've had at least one report of a crash on a page where document is nil here.
+ // Unfortunately that page no longer exists, but we'll make this code robust against
+ // that anyway.
+ // FIXME: Much code in this class assumes document is non-nil; it would be better to
+ // ensure that document can never be nil.
+ KHTMLPart *part = nil;
+ KHTMLView *view = nil;
+
+ if (document && document->document()) {
+ part = document->document()->part();
+ view = document->document()->view();
+ // Since event handling code could cause this object to be deleted, grab a reference to the view now
+ if (view)
+ view->ref();
+ }
bool ret = dispatchGenericEvent( evt, exceptioncode );