Skip to content

Commit

Permalink
Fix exception on zero-length buffers
Browse files Browse the repository at this point in the history
This is an issue in node.js, but let’s fix it here so it works today.

Node issue: nodejs/node#4517
  • Loading branch information
feross committed Jan 3, 2016
1 parent 6b55454 commit 32f3d1b
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ RandomAccessFile.prototype.close = function(callback) {
RandomAccessFile.prototype.read = function(offset, length, callback) {
this.open(function(err, self) {
if (err) return callback(err);

if (length === 0) return callback(null, new Buffer(0));

fs.read(self.fd, alloc(length), 0, length, offset, function(err, read, buffer) {
if (read !== buffer.length) return callback(new Error('range not satisfied'));
callback(err, buffer);
Expand Down

0 comments on commit 32f3d1b

Please sign in to comment.