Skip to content


sourceElement can become NULL in function clickHandler #814

mgc8 opened this Issue · 2 comments

2 participants


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')) {

Keywords: clickHandler, sourceElement, null


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.,



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

@mgc8 mgc8 added this to the Piwik 0.4.1 milestone
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.