diff options
author | Jeremy Martin <jmar777@gmail.com> | 2013-11-22 09:17:16 -0500 |
---|---|---|
committer | Ben Noordhuis <info@bnoordhuis.nl> | 2013-11-22 17:42:34 +0100 |
commit | 71aabedad422748e67d1aab18742d03b829d95c9 (patch) | |
tree | 93b5b859f343a81c1ffd3b7e96ea0ac3f22f9068 /lib | |
parent | a34bbaf31bd327a616adb3ef670174228924a80a (diff) | |
download | nodejs-71aabedad422748e67d1aab18742d03b829d95c9.tar.gz nodejs-71aabedad422748e67d1aab18742d03b829d95c9.tar.bz2 nodejs-71aabedad422748e67d1aab18742d03b829d95c9.zip |
events: fix TypeError in removeAllListeners
Check that `listeners` is actually an array before trying to manipulate it
because it won't be if no regular event listeners have been registered yet
but there are 'removeListener' event listeners.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/events.js | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/events.js b/lib/events.js index f43df093d..781748ba8 100644 --- a/lib/events.js +++ b/lib/events.js @@ -263,7 +263,7 @@ EventEmitter.prototype.removeAllListeners = function(type) { if (typeof listeners === 'function') { this.removeListener(type, listeners); - } else { + } else if (Array.isArray(listeners)) { // LIFO order while (listeners.length) this.removeListener(type, listeners[listeners.length - 1]); |