fs: fix fs.readFileSync fd leak when get RangeError

This commit is contained in:
Jackson Tian 2014-08-06 11:21:59 +08:00 committed by Timothy J Fontaine
parent 70cc9968f6
commit cc08106d62

View File

@ -304,7 +304,13 @@ fs.readFileSync = function(path, options) {
if (size === 0) {
buffers = [];
} else {
buffer = new Buffer(size);
var threw = true;
try {
buffer = new Buffer(size);
threw = false;
} finally {
if (threw) fs.closeSync(fd);
}
}
var done = false;