Skip to content

Commit

Permalink
uv__fs_buf_iter: don't nullify req->bufs on EINTR
Browse files Browse the repository at this point in the history
uv__fs_buf_iter currently sets req->bufs to NULL
after it is done, but if the operation fails with EINTR
then it will be retried, at which point it expects
the bufs to not be NULL, causing a seg fault as in
nodejs/node#4291.

uv__fs_buf_iter should not set req->bufs to NULL
if the operation fails with EINTR.

Also, when it sets req->bufs to NULL, it should set
req->nbufs to 0 as well, so we don't have the messy
situation of a positive nbufs with no actual bufs.
  • Loading branch information
Dave committed Dec 20, 2015
1 parent c861972 commit 05fe26a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/unix/fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,11 @@ static ssize_t uv__fs_buf_iter(uv_fs_t* req, uv__fs_buf_iter_processor process)

if (bufs != req->bufsml)
uv__free(bufs);
req->bufs = NULL;

if (!(errno == EINTR && total == -1)) {
req->bufs = NULL;
req->nbufs = 0;
}

return total;
}
Expand Down

0 comments on commit 05fe26a

Please sign in to comment.