diff options
author | Ben Noordhuis <info@bnoordhuis.nl> | 2012-12-11 14:45:45 +0100 |
---|---|---|
committer | Ben Noordhuis <info@bnoordhuis.nl> | 2012-12-12 09:46:22 +0100 |
commit | 6e97b2cc17851a3b96cd01bac40c82573650ce6b (patch) | |
tree | ed596edbddcfcb528bd509715e28b44abcbc1c28 /lib | |
parent | 65d824b488793ba8b92dfcf6edc6e87f41745580 (diff) | |
download | node-new-6e97b2cc17851a3b96cd01bac40c82573650ce6b.tar.gz |
fs: fix ReadStream fd leak
Close the file descriptor when a read operation fails.
Fixes #4387.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/fs.js | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -1318,8 +1318,11 @@ ReadStream.prototype._read = function() { function afterRead(err, bytesRead) { self.reading = false; if (err) { - self.emit('error', err); - self.readable = false; + fs.close(self.fd, function() { + self.fd = null; + self.emit('error', err); + self.readable = false; + }); return; } |