diff options
author | Yoshihiro Kikuchi <yknetg@gmail.com> | 2011-12-18 09:22:22 +0900 |
---|---|---|
committer | Ben Noordhuis <info@bnoordhuis.nl> | 2011-12-18 01:50:01 +0100 |
commit | f2f30286bf5e5332b1e788f3c745c5231e1b098b (patch) | |
tree | ffe445990b3f910e489ffa14080edfe98e613ea9 /lib | |
parent | 6df7bdd954efb817b50dafad7f90a1285c59c0c9 (diff) | |
download | node-f2f30286bf5e5332b1e788f3c745c5231e1b098b.tar.gz |
timers: fix memory leak in setTimeout
Closing handle is leaked when setTimeout called with arguments which are
1. a callback
2. zero delay
(i.e. setTimeout(function(){}, 0); )
Diffstat (limited to 'lib')
-rw-r--r-- | lib/timers.js | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/timers.js b/lib/timers.js index 39eb4d916..52f357f57 100644 --- a/lib/timers.js +++ b/lib/timers.js @@ -151,7 +151,10 @@ exports.setTimeout = function(callback, after) { timer = new Timer(); if (arguments.length <= 2) { - timer._onTimeout = callback; + timer._onTimeout = function() { + callback(); + timer.close(); + } } else { var args = Array.prototype.slice.call(arguments, 2); timer._onTimeout = function() { |