Skip to content

Commit

Permalink
Do not substract 1 if the buffer length is 0.
Browse files Browse the repository at this point in the history
Start value should be lower or equal with end value. When buffer length is 0 (empty file), this snippet was throwing an error. After this change we substract one unit if the buffer length is not 0.
  • Loading branch information
IonicaBizau committed Sep 26, 2014
1 parent c2c5e6b commit 69d142b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/node-static.js
Expand Up @@ -361,7 +361,7 @@ Server.prototype.stream = function (pathname, files, buffer, startByte, res, cal
flags: 'r',
mode: 0666,
start: startByte,
end: startByte + buffer.length - 1
end: startByte + (buffer.length ? buffer.length - 1 : buffer.length)
}).on('data', function (chunk) {
// Bounds check the incoming chunk and offset, as copying
// a buffer from an invalid offset will throw an error and crash
Expand Down

0 comments on commit 69d142b

Please sign in to comment.