projects
/
platform
/
upstream
/
nodejs.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
c862c03
)
fs: close file if fstat() fails in readFile()
author
cjihrig
<cjihrig@gmail.com>
Wed, 28 May 2014 22:34:04 +0000
(18:34 -0400)
committer
Bert Belder
<bertbelder@gmail.com>
Thu, 29 May 2014 01:58:32 +0000
(18:58 -0700)
Currently, if fstat() fails in readFile(), the callback
is invoked without closing the file. This commit closes
the file before calling back.
Closes #7697
lib/fs.js
patch
|
blob
|
history
diff --git
a/lib/fs.js
b/lib/fs.js
index b7d47ed3a4d89ba2b1c6a7a4eadac5332bdb0320..8f95d624ae73d05fc7c6e55f0183ce5546303fb5 100644
(file)
--- a/
lib/fs.js
+++ b/
lib/fs.js
@@
-208,7
+208,12
@@
fs.readFile = function(path, options, callback_) {
fd = fd_;
fs.fstat(fd, function(er, st) {
- if (er) return callback(er);
+ if (er) {
+ return fs.close(fd, function() {
+ callback(er);
+ });
+ }
+
size = st.size;
if (size === 0) {
// the kernel lies about many files.