Bug 17956 - possible write to freed memory in EventTargetNode::dispatchSimulatedMouseEvent()
Summary: possible write to freed memory in EventTargetNode::dispatchSimulatedMouseEvent()
Status: RESOLVED WORKSFORME
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC Windows XP
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2008-03-19 14:14 PDT by Eric Roman
Modified: 2009-08-12 16:49 PDT (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Eric Roman 2008-03-19 14:14:27 PDT
Not certain about this, but it looks like if the event handler deletes the node within dispatchSimulatedMouseEvent(), there can be a subsequent assignment to freed memory:

EventTargetNode::dispatchSimulatedMouseEvent(...) {
    ...

    m_dispatchingSimulatedEvent = true;

   
    // <--- The event handler may end up deleting "this" --->
    dispatchMouseEvent(...);
   
    // <--- Could this assignment happen to freed memory? --->
    m_dispatchingSimulatedEvent = false;
}

I ran into a problem when using an access key that deleted the anchor (LayoutTests/fast/events/access-key-self-destruct.html) -- however I am not certain if there were other modifications in my code that could have caused this problem.

Can someone familiar with the method comment if this is a problem?

(I see that EventTargetNode::dispatchMouseEvent() protects "this" from deletion, why does this block not require it too?)
Comment 1 Mark Rowe (bdash) 2008-03-19 14:19:58 PDT
It should be possible to construct a test case which crashes due to this issue.  It may require GuardMalloc to be enabled to reproducibly crash though.
Comment 2 Mark Rowe (bdash) 2008-03-19 14:20:10 PDT
<rdar://problem/5808517>
Comment 3 Adele Peterson 2008-04-01 17:44:08 PDT
I've been trying to create a test case where the node gets destroyed that early, and I've been unsuccessful.  I think its because the Event keeps a RefPtr to the EventTarget...and dispatchSimulatedClick has a RefPtr for the event, so the event and the target node can't get destroyed until after dispatchSimulatedClick exits.  Someone should check my logic on that though...
Comment 4 Eric Seidel (no email) 2008-05-16 13:50:33 PDT
The m_dispatchingSimulatedMouseEvent bool is gone from TOT.  This bug can be closed.
Comment 5 David Kilzer (:ddkilzer) 2009-08-12 16:49:42 PDT
(In reply to comment #4)
> The m_dispatchingSimulatedMouseEvent bool is gone from TOT.  This bug can be
> closed.

The m_dispatchingSimulatedEvent bool was removed in r31767.

<http://trac.webkit.org/changeset/31767>