summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorBen Noordhuis <info@bnoordhuis.nl>2012-12-11 14:45:45 +0100
committerBen Noordhuis <info@bnoordhuis.nl>2012-12-12 09:46:22 +0100
commit6e97b2cc17851a3b96cd01bac40c82573650ce6b (patch)
treeed596edbddcfcb528bd509715e28b44abcbc1c28 /lib
parent65d824b488793ba8b92dfcf6edc6e87f41745580 (diff)
downloadnode-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.js7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/fs.js b/lib/fs.js
index 62cbcf01ba..d9a0a110ea 100644
--- a/lib/fs.js
+++ b/lib/fs.js
@@ -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;
}