You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fs.read into zero buffer should not throw exception #4517
Given a file descriptor fd that references a non-zero-length file, I expect this code to work:
varbuf=newBuffer(0)// Read zero bytes into offset 0 of `buf`fs.read(fd,buf,0,0,0,function(err,bytesRead,buffer){console.log('got buffer',buffer)}
Instead it throws an exception because it assumes that offset is out bounds because it starts at the end of the buffer (based on the buffer's length). If length was a positive number, this would be out of bounds. But when length is 0, an offset that starts at the end of the buffer is fine.
I expect a buffer of length zero to be returned in the callback, with no error, and no thrown exception.
Activity
feross commentedon Jan 3, 2016
Sent a PR that fixes the issue: #4518
fs: fs.read into zero buffer should not throw exception
fs: fs.read into zero buffer should not throw exception