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:
70cc996
)
fs: fix fs.readFileSync fd leak when get RangeError
author
Jackson Tian
<shyvo1987@gmail.com>
Wed, 6 Aug 2014 03:21:59 +0000
(11:21 +0800)
committer
Timothy J Fontaine
<tjfontaine@gmail.com>
Thu, 7 Aug 2014 18:27:12 +0000
(11:27 -0700)
lib/fs.js
patch
|
blob
|
history
diff --git
a/lib/fs.js
b/lib/fs.js
index
990eb6d
..
1e3dc64
100644
(file)
--- a/
lib/fs.js
+++ b/
lib/fs.js
@@
-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;