fix crash when trying to triple click with generated content to the right

Darin Adler darin at apple.com
Thu Dec 11 06:19:25 CET 2003


There's a basic problem with trying to express selection with DOM nodes 
and offsets: You can't express a selection that has a start or end 
point inside generated content. At some point, we will solve that 
problem, but for now, here's a patch that fixes a null-deref triple 
clicking when the line is like this:

     <STYLE>label:after { content: ":"; }</STYLE>
     <LABEL>Date Submitted</LABEL>Tuesday, December 09, 2003

There's probably a better fix than just adding the nil check, but 
that's what I did for now.

-------------- next part --------------
Index: ChangeLog
===================================================================
RCS file: /local/home/cvs/Labyrinth/WebCore/ChangeLog,v
retrieving revision 1.2371
diff -p -u -u -p -r1.2371 ChangeLog
--- ChangeLog	2003/12/11 04:55:47	1.2371
+++ ChangeLog	2003/12/11 05:09:11
@@ -1,3 +1,12 @@
+2003-12-10  Darin Adler  <darin at apple.com>
+
+        Reviewed by Maciej.
+
+        - fixed 3506739: nil-deref in DocumentImpl::setSelection triple clicking (generated content)
+
+        * khtml/khtml_part.cpp: (KHTMLPart::khtmlMousePressEvent): Check for the case where
+        m_selectionEnd is 0. This doesn't fix the behavior completely, but it does prevent a crash.
+
 2003-12-10  Maciej Stachowiak  <mjs at apple.com>
 
         Reviewed by Richard.
Index: khtml/khtml_part.cpp
===================================================================
RCS file: /local/home/cvs/Labyrinth/WebCore/khtml/khtml_part.cpp,v
retrieving revision 1.169
diff -p -u -u -p -r1.169 khtml/khtml_part.cpp
--- khtml/khtml_part.cpp	2003/12/11 01:47:07	1.169
+++ khtml/khtml_part.cpp	2003/12/11 05:09:15
@@ -4613,7 +4613,7 @@ void KHTMLPart::khtmlMousePressEvent( kh
                 }
             }
         }
-        if (d->m_selectionStart == 0)
+        if (d->m_selectionStart == 0 || d->m_selectionEnd == 0)
             d->m_doc->clearSelection();
         else{
             d->m_initialSelectionStart = d->m_selectionStart;
@@ -4652,7 +4652,7 @@ void KHTMLPart::khtmlMousePressEvent( kh
                 startAndEndLineNodesIncludingNode (node, startOffset, d->m_selectionStart, d->m_startOffset, d->m_selectionEnd, d->m_endOffset);
             }
         }
-        if (d->m_selectionStart == 0)
+        if (d->m_selectionStart == 0 || d->m_selectionEnd == 0)
             d->m_doc->clearSelection();
         else {
             d->m_initialSelectionStart = d->m_selectionStart;
-------------- next part --------------


     -- Darin


More information about the Khtml-devel mailing list