fs: close file if fstat() fails in readFile()
Currently, if fstat() fails in readFile(), the callback is invoked without closing the file. This commit closes the file before calling back. Closes #7697
This commit is contained in:
parent
c862c03485
commit
72cc66e503
@ -208,7 +208,12 @@ fs.readFile = function(path, options, callback_) {
|
|||||||
fd = fd_;
|
fd = fd_;
|
||||||
|
|
||||||
fs.fstat(fd, function(er, st) {
|
fs.fstat(fd, function(er, st) {
|
||||||
if (er) return callback(er);
|
if (er) {
|
||||||
|
return fs.close(fd, function() {
|
||||||
|
callback(er);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
size = st.size;
|
size = st.size;
|
||||||
if (size === 0) {
|
if (size === 0) {
|
||||||
// the kernel lies about many files.
|
// the kernel lies about many files.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user