<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>159632</bug_id>
          
          <creation_ts>2016-07-11 10:55:17 -0700</creation_ts>
          <short_desc>Possible null dereference under EventHandler::dispatchMouseEvent()</short_desc>
          <delta_ts>2016-07-11 23:32:25 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>HTML Editing</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Chris Dumez">cdumez</reporter>
          <assigned_to name="Chris Dumez">cdumez</assigned_to>
          <cc>commit-queue</cc>
    
    <cc>enrica</cc>
    
    <cc>kling</cc>
    
    <cc>rniwa</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1209699</commentid>
    <comment_count>0</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2016-07-11 10:55:17 -0700</bug_when>
    <thetext>Possible null dereference under EventHandler::dispatchMouseEvent():
Thread[0] EXC_BAD_ACCESS (SIGSEGV) (KERN_INVALID_ADDRESS at 0x0000000000000008)
[  0] 0x00007fff9312d6e4 WebCore`WebCore::Range::compareNode(WebCore::Node&amp;, int&amp;) const + 36 at Range.cpp:298:9
       294 	        // Firefox doesn&apos;t throw an exception for this case; it returns 0.
       295 	        return NODE_BEFORE;
       296 	    }
       297 	
    -&gt; 298 	    if (&amp;refNode.document() != &amp;ownerDocument()) {
       299 	        // Firefox doesn&apos;t throw an exception for this case; it returns 0.
       300 	        return NODE_BEFORE;
       301 	    }
       302 	
    

     0x00007fff9312d6d6:    testb $0x1, 0x15(%rsi)
     0x00007fff9312d6da:       je 0xce874e             ; &lt;+142&gt; at Range.cpp:323
     0x00007fff9312d6dc:     movq 0x20(%rsi), %rax
     0x00007fff9312d6e0:     movq 0x8(%rax), %rax
 -&gt;  0x00007fff9312d6e4:     cmpq 0x8(%r15), %rax
     0x00007fff9312d6e8:      jne 0xce874e             ; &lt;+142&gt; at Range.cpp:323
     0x00007fff9312d6ea:     movq 0x18(%rsi), %r12
     0x00007fff9312d6ee:     movq %rsi, %rdi
     0x00007fff9312d6f1:    callq 0x14c240             ; WebCore::Node::computeNodeIndex at Node.cpp:781

[  1] 0x00007fff925b46b4 WebCore`WebCore::EventHandler::dispatchMouseEvent(WTF::AtomicString const&amp;, WebCore::Node*, bool, int, WebCore::PlatformMouseEvent const&amp;, bool) + 324 at EventHandler.cpp:2515:24
       2511	                // node on mouse down if it&apos;s selected and inside a focused node. It will be
       2512	                // focused if the user does a mouseup over it, however, because the mouseup
       2513	                // will set a selection inside it, which will call setFocuseNodeIfNeeded.
       2514	                if (m_frame.selection().isRange()
    -&gt; 2515	                    &amp;&amp; m_frame.selection().toNormalizedRange()-&gt;compareNode(*element, IGNORE_EXCEPTION) == Range::NODE_INSIDE
       2516	                    &amp;&amp; element-&gt;isDescendantOf(m_frame.document()-&gt;focusedElement()))
       2517	                    return true;
       2518	                    
       2519	                break;
    
[  2] 0x00007fff925b83f7 WebCore`WebCore::EventHandler::handleMousePressEvent(WebCore::PlatformMouseEvent const&amp;) + 1799 at EventHandler.cpp:1708:26
       1704	    }
       1705	
       1706	    m_frame.selection().setCaretBlinkingSuspended(true);
       1707	
    -&gt; 1708	    bool swallowEvent = !dispatchMouseEvent(eventNames().mousedownEvent, mouseEvent.targetNode(), true, m_clickCount, platformMouseEvent, true);
       1709	    m_capturesDragging = !swallowEvent || mouseEvent.scrollbar();
       1710	
       1711	    // If the hit testing originally determined the event was in a scrollbar, refetch the MouseEventWithHitTestResults
       1712	    // in case the scrollbar widget was destroyed when the mouse event was handled.
    
[  3] 0x00007fff926dc4bc WebCore`WebCore::EventHandler::passMousePressEventToSubframe(WebCore::MouseEventWithHitTestResults&amp;, WebCore::Frame*) + 76 at EventHandlerMac.mm:692:5
       688 	    if (frameHasPlatformWidget(m_frame))
       689 	        return passSubframeEventToSubframe(mev, subframe);
       690 	
       691 	    // WebKit2 code path.
    -&gt; 692 	    subframe-&gt;eventHandler().handleMousePressEvent(mev.event());
       693 	    return true;
       694 	}
       695 	
       696 	bool EventHandler::passMouseMoveEventToSubframe(MouseEventWithHitTestResults&amp; mev, Frame* subframe, HitTestResult* hoveredNode)
    
[  4] 0x00007fff925b8015 WebCore`WebCore::EventHandler::handleMousePressEvent(WebCore::PlatformMouseEvent const&amp;) + 805 at EventHandler.cpp:1661:21</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1209700</commentid>
    <comment_count>1</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2016-07-11 10:55:50 -0700</bug_when>
    <thetext>&lt;rdar://problem/27247619&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1209701</commentid>
    <comment_count>2</comment_count>
      <attachid>283323</attachid>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2016-07-11 10:57:59 -0700</bug_when>
    <thetext>Created attachment 283323
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1209791</commentid>
    <comment_count>3</comment_count>
      <attachid>283323</attachid>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2016-07-11 13:54:33 -0700</bug_when>
    <thetext>Comment on attachment 283323
Patch

Clearing flags on attachment: 283323

Committed r203082: &lt;http://trac.webkit.org/changeset/203082&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1209792</commentid>
    <comment_count>4</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2016-07-11 13:54:37 -0700</bug_when>
    <thetext>All reviewed patches have been landed.  Closing bug.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1209954</commentid>
    <comment_count>5</comment_count>
      <attachid>283323</attachid>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2016-07-11 23:32:25 -0700</bug_when>
    <thetext>Comment on attachment 283323
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=283323&amp;action=review

&gt; Source/WebCore/ChangeLog:9
&gt; +        FrameSelection::toNormalizedRange() can return null even when FrameSelection::isRange()

Test?</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>283323</attachid>
            <date>2016-07-11 10:57:59 -0700</date>
            <delta_ts>2016-07-11 13:54:33 -0700</delta_ts>
            <desc>Patch</desc>
            <filename>bug-159632-20160711105717.patch</filename>
            <type>text/plain</type>
            <size>2313</size>
            <attacher name="Chris Dumez">cdumez</attacher>
            
              <data encoding="base64">U3VidmVyc2lvbiBSZXZpc2lvbjogMjAzMDY1CmRpZmYgLS1naXQgYS9Tb3VyY2UvV2ViQ29yZS9D
aGFuZ2VMb2cgYi9Tb3VyY2UvV2ViQ29yZS9DaGFuZ2VMb2cKaW5kZXggOWI1NzUyZTQ4NjZlYzc0
MjhkNDUyYTk0ZWI5NTUyMTQ4NzFmNjA2NS4uMjBjZDU4YmNkODZkZDNhMGQ1MTgzOWQxNDE4MTVl
ODY5YmIwMjVmYSAxMDA2NDQKLS0tIGEvU291cmNlL1dlYkNvcmUvQ2hhbmdlTG9nCisrKyBiL1Nv
dXJjZS9XZWJDb3JlL0NoYW5nZUxvZwpAQCAtMSwzICsxLDE3IEBACisyMDE2LTA3LTExICBDaHJp
cyBEdW1leiAgPGNkdW1lekBhcHBsZS5jb20+CisKKyAgICAgICAgUG9zc2libGUgbnVsbCBk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gICAgICAg
ICAgICAgaWYgKGF1dG8gcmFuZ2UgPSBtX2ZyYW1lLnNlbGVjdGlvbigpLnRvTm9ybWFsaXplZFJh
bmdlKCkpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIGlmIChyYW5nZS0+Y29tcGFyZU5vZGUo
KmVsZW1lbnQsIElHTk9SRV9FWENFUFRJT04pID09IFJhbmdlOjpOT0RFX0lOU0lERSAmJiBlbGVt
ZW50LT5pc0Rlc2NlbmRhbnRPZihtX2ZyYW1lLmRvY3VtZW50KCktPmZvY3VzZWRFbGVtZW50KCkp
KQorICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOworICAgICAgICAgICAg
ICAgICAgICB9CisgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAKICAgICAg
ICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgIH0K
</data>

          </attachment>
      

    </bug>

</bugzilla>