Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

fs: fix infinite loop in fs.readFileSync()

Fix an infinite loop in the case where the file got truncated by a concurrent
writer while fs.readFileSync() was busy reading in the file.
  • Loading branch information...
bnoordhuis committed Jun 12, 2012
1 parent 8f1aaee commit e6c461997855151feea48d6e59f9c28d79f4eb58
Showing with 1 addition and 6 deletions.
  1. +1 −6 lib/fs.js
@@ -219,12 +219,7 @@ fs.readFileSync = function(path, encoding) {
}

pos += bytesRead;

if (size !== 0) {
done = pos >= size;
} else {
done = bytesRead >= 0;
}
done = (bytesRead === 0) || (size !== 0 && pos >= size);
}

fs.closeSync(fd);

0 comments on commit e6c4619

Please sign in to comment.
You can’t perform that action at this time.