Opened 5 years ago

Closed 5 years ago

#814 closed Bug (fixed)

sourceElement can become NULL in function clickHandler

Reported by: mgc8 Owned by:
Priority: low Milestone: Piwik 0.4.1
Component: Core Keywords: clickHandler, sourceElement, null
Cc: Sensitive:

Description

In the function clickHandler(clickEvent) at line 661 in piwik.js, the while loop executes

sourceElement = sourceElement.parentNode;

without checking sourceElement.parentNode. This can lead to sourceElement becoming NULL and errors in the following code.

A patch is simple enough:

--while ((tag = sourceElement.tagName) != 'A' && tag != 'AREA') {
++while ((sourceElement.parentNode) && ((tag = sourceElement.tagName) != 'A' && tag != 'AREA')) {

Thanks,
Mihnea

Change History (2)

comment:1 Changed 5 years ago by vipsoft (robocoder)

  • Milestone set to 1 - Piwik 0.4.1

True, but we attach the click handler using the anchor tags returned by document.links. So, the only time we could enter the loop is when the web site did something silly, i.e.,

tracker->addListener(clickable_non_anchor_element_with_no_anchor_element_ancestors).

comment:2 Changed 5 years ago by vipsoft (robocoder)

  • Resolution set to fixed
  • Status changed from new to closed

(In [1243]) Fixes #814 - guard against:

addListener(clickable_non_anchor_element_with_no_anchor_element_ancestors)

Note: See TracTickets for help on using tickets.