Skip to content

Commit 32f3d1b

Browse files
committed
Fix exception on zero-length buffers
This is an issue in node.js, but let’s fix it here so it works today. Node issue: nodejs/node#4517
1 parent 6b55454 commit 32f3d1b

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ RandomAccessFile.prototype.close = function(callback) {
7474
RandomAccessFile.prototype.read = function(offset, length, callback) {
7575
this.open(function(err, self) {
7676
if (err) return callback(err);
77+
78+
if (length === 0) return callback(null, new Buffer(0));
79+
7780
fs.read(self.fd, alloc(length), 0, length, offset, function(err, read, buffer) {
7881
if (read !== buffer.length) return callback(new Error('range not satisfied'));
7982
callback(err, buffer);

0 commit comments

Comments
 (0)